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

Error when running the conversation_GAN.py #3

Open
balagopal24 opened this issue Jun 14, 2018 · 5 comments
Open

Error when running the conversation_GAN.py #3

balagopal24 opened this issue Jun 14, 2018 · 5 comments

Comments

@balagopal24
Copy link

Traceback (most recent call last):
File "conversation_GAN.py", line 136, in
input_context = Input(shape=(maxlen_input,), dtype='int32', name='the context text')
File "/home/bala/.local/lib/python2.7/site-packages/keras/engine/input_layer.py", line 176, in Input
input_tensor=tensor)
File "/home/bala/.local/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/home/bala/.local/lib/python2.7/site-packages/keras/engine/input_layer.py", line 85, in init
name=self.name)
File "/home/bala/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 514, in placeholder
x = tf.placeholder(dtype, shape=shape, name=name)
File "/home/bala/.local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1808, in placeholder
return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name)
File "/home/bala/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 4848, in placeholder
"Placeholder", dtype=dtype, shape=shape, name=name)
File "/home/bala/.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 "/home/bala/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 5982, in enter
return self._name_scope.enter()
File "/usr/lib/python2.7/contextlib.py", line 17, in enter
return self.gen.next()
File "/home/bala/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 4105, in name_scope
raise ValueError("'%s' is not a valid scope name" % name)
ValueError: 'the context text' is not a valid scope name

@oswaldoludwig
Copy link
Owner

oswaldoludwig commented Jun 14, 2018

You can remove the parameter "name", so Line 136 can be rewritten as: input_context = Input(shape=(maxlen_input,), dtype='int32')

@johndpope
Copy link

it's possible to upgrade any python2 code to python 3 automatically using the following command.

2to3 *.py -w
this will convert file to python3
the error I get in python 3 is more accurately

raise ValueError("'%s' is not a valid scope name" % name)

ValueError: 'the context text' is not a valid scope name

this can be resolved by removing the spaces in the name parameter.
I believe you still want a name params / scope built into the graph rather than ditching them.

side note - I've been tinkering with livepython to spit out tensorflow graph at run time.
screen shot 2018-06-21 at 5 16 13 pm
agermanidis/livepython#24

@johndpope
Copy link

problem I get with replacing strings

python conversation_GAN.py
/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/site-packages/h5py/__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
 from ._conv import register_converters as _register_converters
Using TensorFlow backend.
/Users/jpope/miniconda2/envs/tensorflow/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: compiletime version 3.6 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.5
 return f(*args, **kwds)
Starting the model...
conversation_GAN.py:138: UserWarning: Update your `LSTM` call to the Keras 2 API: `LSTM(300, name="Encodecontext", kernel_initializer="lecun_uniform")`
 LSTM_encoder = LSTM(sentence_embedding_size, init= 'lecun_uniform', name='Encodecontext')
conversation_GAN.py:139: UserWarning: Update your `LSTM` call to the Keras 2 API: `LSTM(300, name="Encodeansweruptothecurrenttoken", kernel_initializer="lecun_uniform")`
 LSTM_decoder = LSTM(sentence_embedding_size, init= 'lecun_uniform', name='Encodeansweruptothecurrenttoken')
Traceback (most recent call last):
 File "conversation_GAN.py", line 148, in <module>
   merge_layer = merge([context_embedding, answer_embedding], mode='concat', concat_axis=1, name='concatenatetheembeddingsofthecontextandtheansweruptocurrenttoken')
TypeError: 'module' object is not callable

@johndpope
Copy link

related - zhixuhao/unet#45

@johndpope
Copy link

johndpope commented Jun 28, 2018

thanks @oswaldoludwig - I got it working in python 3

https://gist.github.com/johndpope/62c3e2117c9de625b7f82f3356a7430d

Using TensorFlow backend.
Starting the model...
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to
==================================================================================================
thecontexttext (InputLayer)     (None, 50)           0
__________________________________________________________________________________________________
theanswertextuptothecurrenttoke (None, 50)           0
__________________________________________________________________________________________________
Shared (Embedding)              (None, 50, 100)      700000      thecontexttext[0][0]
                                                                 theanswertextuptothecurrenttoken[
__________________________________________________________________________________________________
Encodecontext (LSTM)            (None, 300)          481200      Shared[0][0]
__________________________________________________________________________________________________
Encodeansweruptothecurrenttoken (None, 300)          481200      Shared[1][0]
__________________________________________________________________________________________________
concatenate_1 (Concatenate)     (None, 600)          0           Encodecontext[0][0]
                                                                 Encodeansweruptothecurrenttoken[0
__________________________________________________________________________________________________
reluactivation (Dense)          (None, 3500)         2103500     concatenate_1[0][0]
__________________________________________________________________________________________________
dense_1 (Dense)                 (None, 7000)         24507000    reluactivation[0][0]
==================================================================================================
Total params: 28,272,900
Trainable params: 28,272,900
Non-trainable params: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants