Skip to content
This repository has been archived by the owner on Jan 1, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed bugs in chatbot
  • Loading branch information
chiphuyen committed Mar 14, 2018
1 parent 89772fa commit ecde8d0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
4 changes: 2 additions & 2 deletions assignments/chatbot/chatbot.py
Expand Up @@ -169,7 +169,8 @@ def _get_user_input():
""" Get user's input, which will be transformed into encoder input later """
print("> ", end="")
sys.stdout.flush()
return sys.stdin.readline()
text = sys.stdin.readline()
return data.tokenize_helper(text)

def _find_right_bucket(length):
""" Find the proper bucket for an encoder input based on its length """
Expand All @@ -183,7 +184,6 @@ def _construct_response(output_logits, inv_dec_vocab):
This is a greedy decoder - outputs are just argmaxes of output_logits.
"""
print(output_logits[0])
outputs = [int(np.argmax(logit, axis=1)) for logit in output_logits]
# If there is an EOS symbol in outputs, cut them at that point.
if config.EOS_ID in outputs:
Expand Down
2 changes: 0 additions & 2 deletions assignments/chatbot/config.py
Expand Up @@ -48,5 +48,3 @@
MAX_GRAD_NORM = 5.0

NUM_SAMPLES = 512
ENC_VOCAB = 24133
DEC_VOCAB = 22879
25 changes: 0 additions & 25 deletions assignments/chatbot/model.py
Expand Up @@ -86,31 +86,6 @@ def _seq2seq_f(encoder_inputs, decoder_inputs, do_decode):
config.BUCKETS,
lambda x, y: _seq2seq_f(x, y, False),
softmax_loss_function=self.softmax_loss_function)

# if self.fw_only:
# self.outputs, self.losses = tf.contrib.training.bucket_by_sequence_length(
# self.encoder_inputs,
# self.decoder_inputs,
# self.targets,
# self.decoder_masks,
# config.BUCKETS,
# lambda x, y: _seq2seq_f(x, y, True),
# softmax_loss_function=self.softmax_loss_function)
# # If we use output projection, we need to project outputs for decoding.
# if self.output_projection:
# for bucket in range(len(config.BUCKETS)):
# self.outputs[bucket] = [tf.matmul(output,
# self.output_projection[0]) + self.output_projection[1]
# for output in self.outputs[bucket]]
# else:
# self.outputs, self.losses = tf.contrib.training.bucket_by_sequence_length(
# self.encoder_inputs,
# self.decoder_inputs,
# self.targets,
# self.decoder_masks,
# config.BUCKETS,
# lambda x, y: _seq2seq_f(x, y, False),
# softmax_loss_function=self.softmax_loss_function)
print('Time:', time.time() - start)

def _creat_optimizer(self):
Expand Down

0 comments on commit ecde8d0

Please sign in to comment.