"docs/vscode:/vscode.git/clone" did not exist on "b53c91d00b32b4d79a565f4f6e9c0ef39bcfa3d1"
Commit 296d4f65 authored by Ivan Bogatyy's avatar Ivan Bogatyy
Browse files
parents 9a463f1e 277f99c7
...@@ -319,7 +319,7 @@ their use, consider the following example. ...@@ -319,7 +319,7 @@ their use, consider the following example.
def MyNewOp(inputs): def MyNewOp(inputs):
varA = ... varA = ...
varB = ... varB = ...
outputs = tf.mul(varA, inputs) + varB outputs = tf.multiply(varA, inputs) + varB
return outputs return outputs
``` ```
......
...@@ -227,8 +227,9 @@ class Seq2SeqAttentionModel(object): ...@@ -227,8 +227,9 @@ class Seq2SeqAttentionModel(object):
def sampled_loss_func(inputs, labels): def sampled_loss_func(inputs, labels):
with tf.device('/cpu:0'): # Try gpu. with tf.device('/cpu:0'): # Try gpu.
labels = tf.reshape(labels, [-1, 1]) labels = tf.reshape(labels, [-1, 1])
return tf.nn.sampled_softmax_loss(w_t, v, inputs, labels, return tf.nn.sampled_softmax_loss(
hps.num_softmax_samples, vsize) weights=w_t, biases=v, labels=labels, inputs=inputs,
num_sampled=hps.num_softmax_samples, num_classes=vsize)
if hps.num_softmax_samples != 0 and hps.mode == 'train': if hps.num_softmax_samples != 0 and hps.mode == 'train':
self._loss = seq2seq_lib.sampled_sequence_loss( self._loss = seq2seq_lib.sampled_sequence_loss(
......
...@@ -110,7 +110,7 @@ class PTBModel(object): ...@@ -110,7 +110,7 @@ class PTBModel(object):
# different than reported in the paper. # different than reported in the paper.
def lstm_cell(): def lstm_cell():
return tf.contrib.rnn.BasicLSTMCell( return tf.contrib.rnn.BasicLSTMCell(
size, forget_bias=0.0, state_is_tuple=True, reuse=tf.get_variable_scope().reuse) size, forget_bias=0.0, state_is_tuple=True)
attn_cell = lstm_cell attn_cell = lstm_cell
if is_training and config.keep_prob < 1: if is_training and config.keep_prob < 1:
def attn_cell(): def attn_cell():
......
...@@ -100,13 +100,13 @@ class Seq2SeqModel(object): ...@@ -100,13 +100,13 @@ class Seq2SeqModel(object):
b = tf.get_variable("proj_b", [self.target_vocab_size], dtype=dtype) b = tf.get_variable("proj_b", [self.target_vocab_size], dtype=dtype)
output_projection = (w, b) output_projection = (w, b)
def sampled_loss(labels, inputs): def sampled_loss(labels, logits):
labels = tf.reshape(labels, [-1, 1]) labels = tf.reshape(labels, [-1, 1])
# We need to compute the sampled_softmax_loss using 32bit floats to # We need to compute the sampled_softmax_loss using 32bit floats to
# avoid numerical instabilities. # avoid numerical instabilities.
local_w_t = tf.cast(w_t, tf.float32) local_w_t = tf.cast(w_t, tf.float32)
local_b = tf.cast(b, tf.float32) local_b = tf.cast(b, tf.float32)
local_inputs = tf.cast(inputs, tf.float32) local_inputs = tf.cast(logits, tf.float32)
return tf.cast( return tf.cast(
tf.nn.sampled_softmax_loss( tf.nn.sampled_softmax_loss(
weights=local_w_t, weights=local_w_t,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment