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
520b557e
Commit
520b557e
authored
Jan 20, 2017
by
Neal Wu
Browse files
Force new instance creation in MultiRNNCell (See also CL 145094809)
parent
a689e124
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
9 deletions
+14
-9
tutorials/rnn/ptb/ptb_word_lm.py
tutorials/rnn/ptb/ptb_word_lm.py
+8
-5
tutorials/rnn/translate/seq2seq_model.py
tutorials/rnn/translate/seq2seq_model.py
+6
-4
No files found.
tutorials/rnn/ptb/ptb_word_lm.py
View file @
520b557e
...
@@ -108,13 +108,16 @@ class PTBModel(object):
...
@@ -108,13 +108,16 @@ class PTBModel(object):
# Slightly better results can be obtained with forget gate biases
# Slightly better results can be obtained with forget gate biases
# initialized to 1 but the hyperparameters of the model would need to be
# initialized to 1 but the hyperparameters of the model would need to be
# different than reported in the paper.
# different than reported in the paper.
lstm_cell
=
tf
.
contrib
.
rnn
.
BasicLSTMCell
(
def
lstm_cell
():
size
,
forget_bias
=
0.0
,
state_is_tuple
=
True
)
return
tf
.
contrib
.
rnn
.
BasicLSTMCell
(
size
,
forget_bias
=
0.0
,
state_is_tuple
=
True
)
attn_cell
=
lstm_cell
if
is_training
and
config
.
keep_prob
<
1
:
if
is_training
and
config
.
keep_prob
<
1
:
lstm_cell
=
tf
.
contrib
.
rnn
.
DropoutWrapper
(
def
attn_cell
():
lstm_cell
,
output_keep_prob
=
config
.
keep_prob
)
return
tf
.
contrib
.
rnn
.
DropoutWrapper
(
lstm_cell
(),
output_keep_prob
=
config
.
keep_prob
)
cell
=
tf
.
contrib
.
rnn
.
MultiRNNCell
(
cell
=
tf
.
contrib
.
rnn
.
MultiRNNCell
(
[
lstm
_cell
]
*
config
.
num_layers
,
state_is_tuple
=
True
)
[
attn
_cell
()
for
_
in
range
(
config
.
num_layers
)]
,
state_is_tuple
=
True
)
self
.
_initial_state
=
cell
.
zero_state
(
batch_size
,
data_type
())
self
.
_initial_state
=
cell
.
zero_state
(
batch_size
,
data_type
())
...
...
tutorials/rnn/translate/seq2seq_model.py
View file @
520b557e
...
@@ -114,12 +114,14 @@ class Seq2SeqModel(object):
...
@@ -114,12 +114,14 @@ class Seq2SeqModel(object):
softmax_loss_function
=
sampled_loss
softmax_loss_function
=
sampled_loss
# Create the internal multi-layer cell for our RNN.
# Create the internal multi-layer cell for our RNN.
single_cell
=
tf
.
nn
.
rnn_cell
.
GRUCell
(
size
)
def
single_cell
():
return
tf
.
nn
.
rnn_cell
.
GRUCell
(
size
)
if
use_lstm
:
if
use_lstm
:
single_cell
=
tf
.
nn
.
rnn_cell
.
BasicLSTMCell
(
size
)
def
single_cell
():
cell
=
single_cell
return
tf
.
nn
.
rnn_cell
.
BasicLSTMCell
(
size
)
cell
=
single_cell
()
if
num_layers
>
1
:
if
num_layers
>
1
:
cell
=
tf
.
nn
.
rnn_cell
.
MultiRNNCell
([
single_cell
]
*
num_layers
)
cell
=
tf
.
nn
.
rnn_cell
.
MultiRNNCell
([
single_cell
()
for
_
in
range
(
num_layers
)
])
# The seq2seq function: we use embedding for the input and attention.
# The seq2seq function: we use embedding for the input and attention.
def
seq2seq_f
(
encoder_inputs
,
decoder_inputs
,
do_decode
):
def
seq2seq_f
(
encoder_inputs
,
decoder_inputs
,
do_decode
):
...
...
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