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
0d8916f4
Commit
0d8916f4
authored
Mar 15, 2017
by
Neal Wu
Committed by
GitHub
Mar 15, 2017
Browse files
Revert 0.12 changes but keep the argument swap
parent
a38bf8d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
tutorials/rnn/translate/seq2seq_model.py
tutorials/rnn/translate/seq2seq_model.py
+7
-7
No files found.
tutorials/rnn/translate/seq2seq_model.py
View file @
0d8916f4
...
...
@@ -100,7 +100,7 @@ class Seq2SeqModel(object):
b
=
tf
.
get_variable
(
"proj_b"
,
[
self
.
target_vocab_size
],
dtype
=
dtype
)
output_projection
=
(
w
,
b
)
def
sampled_loss
(
inputs
,
labels
):
def
sampled_loss
(
inputs
,
labels
):
labels
=
tf
.
reshape
(
labels
,
[
-
1
,
1
])
# We need to compute the sampled_softmax_loss using 32bit floats to
# avoid numerical instabilities.
...
...
@@ -120,17 +120,17 @@ class Seq2SeqModel(object):
# Create the internal multi-layer cell for our RNN.
def
single_cell
():
return
tf
.
nn
.
rnn_cell
.
GRUCell
(
size
)
return
tf
.
contrib
.
rnn
.
GRUCell
(
size
)
if
use_lstm
:
def
single_cell
():
return
tf
.
nn
.
rnn_cell
.
BasicLSTMCell
(
size
)
return
tf
.
contrib
.
rnn
.
BasicLSTMCell
(
size
)
cell
=
single_cell
()
if
num_layers
>
1
:
cell
=
tf
.
nn
.
rnn_cell
.
MultiRNNCell
([
single_cell
()
for
_
in
range
(
num_layers
)])
cell
=
tf
.
contrib
.
rnn
.
MultiRNNCell
([
single_cell
()
for
_
in
range
(
num_layers
)])
# The seq2seq function: we use embedding for the input and attention.
def
seq2seq_f
(
encoder_inputs
,
decoder_inputs
,
do_decode
):
return
tf
.
nn
.
seq2seq
.
embedding_attention_seq2seq
(
return
tf
.
contrib
.
legacy_
seq2seq
.
embedding_attention_seq2seq
(
encoder_inputs
,
decoder_inputs
,
cell
,
...
...
@@ -160,7 +160,7 @@ class Seq2SeqModel(object):
# Training outputs and losses.
if
forward_only
:
self
.
outputs
,
self
.
losses
=
tf
.
nn
.
seq2seq
.
model_with_buckets
(
self
.
outputs
,
self
.
losses
=
tf
.
contrib
.
legacy_
seq2seq
.
model_with_buckets
(
self
.
encoder_inputs
,
self
.
decoder_inputs
,
targets
,
self
.
target_weights
,
buckets
,
lambda
x
,
y
:
seq2seq_f
(
x
,
y
,
True
),
softmax_loss_function
=
softmax_loss_function
)
...
...
@@ -172,7 +172,7 @@ class Seq2SeqModel(object):
for
output
in
self
.
outputs
[
b
]
]
else
:
self
.
outputs
,
self
.
losses
=
tf
.
nn
.
seq2seq
.
model_with_buckets
(
self
.
outputs
,
self
.
losses
=
tf
.
contrib
.
legacy_
seq2seq
.
model_with_buckets
(
self
.
encoder_inputs
,
self
.
decoder_inputs
,
targets
,
self
.
target_weights
,
buckets
,
lambda
x
,
y
:
seq2seq_f
(
x
,
y
,
False
),
...
...
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