Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
c15fada2
Commit
c15fada2
authored
Mar 27, 2017
by
Neal Wu
Browse files
Rewrite to use inspect.getargspec
parent
167b6c69
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
tutorials/rnn/ptb/ptb_word_lm.py
tutorials/rnn/ptb/ptb_word_lm.py
+6
-4
No files found.
tutorials/rnn/ptb/ptb_word_lm.py
View file @
c15fada2
...
...
@@ -56,6 +56,7 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
inspect
import
time
import
numpy
as
np
...
...
@@ -111,13 +112,14 @@ class PTBModel(object):
def
lstm_cell
():
# With the latest TensorFlow source code (as of Mar 27, 2017),
# the BasicLSTMCell will need a reuse parameter which is unfortunately not
# defined in TensorFlow 1.0. To maintain backwards compatibility, we add a
# try-except here:
try
:
# defined in TensorFlow 1.0. To maintain backwards compatibility, we add
# an argument check here:
if
'reuse'
in
inspect
.
getargspec
(
tf
.
contrib
.
rnn
.
BasicLSTMCell
.
__init__
).
args
:
return
tf
.
contrib
.
rnn
.
BasicLSTMCell
(
size
,
forget_bias
=
0.0
,
state_is_tuple
=
True
,
reuse
=
tf
.
get_variable_scope
().
reuse
)
e
xcept
TypeError
:
e
lse
:
return
tf
.
contrib
.
rnn
.
BasicLSTMCell
(
size
,
forget_bias
=
0.0
,
state_is_tuple
=
True
)
attn_cell
=
lstm_cell
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment