oswaldoludwig / Seq2seq-Chatbot-for-Keras

This repository contains a new generative model of chatbot based on seq2seq modeling.
Apache License 2.0
331 stars 98 forks source link

Error while running conversation.py #16

Closed pynchmeister closed 5 years ago

pynchmeister commented 6 years ago

Hello.

I am attempting to chat with the pre-trained model. I have downloaded the files from the dropbox, then I go to the directory for this cloned git and then I run conversation.py

I continue to get this error:

File "/Users/harrislevine/Downloads/Seq2seq-Chatbot-for-Keras-master-2/conversation.py", line 96 if raw_word[-1] <> '!' and raw_word[-1] <> '?' and raw_word[-1] <> '.' and raw_word[-2:] <> '! ' and raw_word[-2:] <> '? ' and raw_word[-2:] <> '. ': ^ SyntaxError: invalid syntax Harriss-MacBook-Pro:~ harrislevine$ cd /Users/harrislevine/Downloads/Seq2seq-Chatbot-for-Keras-master-2 Harriss-MacBook-Pro:Seq2seq-Chatbot-for-Keras-master-2 harrislevine$ python /Users/harrislevine/Downloads/Seq2seq-Chatbot-for-Keras-master-2/conversation.py File "/Users/harrislevine/Downloads/Seq2seq-Chatbot-for-Keras-master-2/conversation.py", line 96 if raw_word[-1] <> '!' and raw_word[-1] <> '?' and raw_word[-1] <> '.' and raw_word[-2:] <> '! ' and raw_word[-2:] <> '? ' and raw_word[-2:] <> '. ': ^ SyntaxError: invalid syntax Harriss-MacBook-Pro:Seq2seq-Chatbot-for-Keras-master-2 harrislevine$

If anyone can point out where I am going wrong it would be much appreciated...

oswaldoludwig commented 6 years ago

You are probably using Python 3 and this project uses Python 2. The comparison operator <> has been removed from Python 3, you should replace it by != along this code.

See: https://stackoverflow.com/questions/40211270/is-there-a-difference-between-and-operators-in-python

pynchmeister commented 6 years ago

Thank you very much!

pynchmeister commented 6 years ago

Although I exceedingly appreciate the previous message's guidance, I have ran into another issue after invoking python2:

Using TensorFlow backend. Starting the model... Traceback (most recent call last): File "conversation.py", line 136, in input_context = Input(shape=(maxlen_input,), dtype='int32', name='the context text') File "/usr/local/lib/python2.7/site-packages/keras/engine/topology.py", line 1457, in Input input_tensor=tensor) File "/usr/local/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/keras/engine/topology.py", line 1366, in init name=self.name) File "/usr/local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 507, in placeholder x = tf.placeholder(dtype, shape=shape, name=name) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1777, in placeholder return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 4521, in placeholder "Placeholder", dtype=dtype, shape=shape, name=name) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 394, in _apply_op_helper with g.as_default(), ops.name_scope(name) as scope: File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 5775, in enter return self._name_scope.enter() File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in enter return self.gen.next() File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3984, in name_scope raise ValueError("'%s' is not a valid scope name" % name) ValueError: 'the context text' is not a valid scope name

Any ideas?

pynchmeister commented 6 years ago

In the meantime I'll give Theano a whirl...

oswaldoludwig commented 6 years ago

The backend is Theano.

BlogBlocks commented 6 years ago

@pynchmeister - Do not use spaces in any of the names ---
Example: for the the context text
use the-context-text