Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions models/dual_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def dual_encoder_model(
# Build the RNN
with tf.variable_scope("rnn") as vs:
# We use an LSTM Cell
cell = tf.nn.rnn_cell.LSTMCell(
cell = tf.contrib.rnn.LSTMCell(
hparams.rnn_dim,
forget_bias=2.0,
use_peepholes=True,
Expand All @@ -51,10 +51,10 @@ def dual_encoder_model(
# Run the utterance and context through the RNN
rnn_outputs, rnn_states = tf.nn.dynamic_rnn(
cell,
tf.concat(0, [context_embedded, utterance_embedded]),
sequence_length=tf.concat(0, [context_len, utterance_len]),
tf.concat( [context_embedded, utterance_embedded],0),
sequence_length=tf.concat([context_len, utterance_len],0),
dtype=tf.float32)
encoding_context, encoding_utterance = tf.split(0, 2, rnn_states.h)
encoding_context, encoding_utterance = tf.split(rnn_states.h, 2, 0)

with tf.variable_scope("prediction") as vs:
M = tf.get_variable("M",
Expand All @@ -68,7 +68,7 @@ def dual_encoder_model(

# Dot product between generated response and actual response
# (c * M) * r
logits = tf.batch_matmul(generated_response, encoding_utterance, True)
logits = tf.matmul(generated_response, encoding_utterance, True)
logits = tf.squeeze(logits, [2])

# Apply sigmoid to convert logits to probabilities
Expand All @@ -78,7 +78,7 @@ def dual_encoder_model(
return probs, None

# Calculate the binary cross-entropy loss
losses = tf.nn.sigmoid_cross_entropy_with_logits(logits, tf.to_float(targets))
losses = tf.nn.sigmoid_cross_entropy_with_logits(logits=logits, labels=tf.to_float(targets))

# Mean loss across the batch of examples
mean_loss = tf.reduce_mean(losses, name="mean_loss")
Expand Down