keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.97k stars 19.46k forks source link

Call signature of tf.concat has changed in Tensorflow 1.0.0rc0 #5238

Closed lfloeer closed 7 years ago

lfloeer commented 7 years ago

Because the call signature of tf.concat has changed to the one of the deprecated tf.concat_v2, the creation of a bidirectional RNN layer fails. This happens in either Version 1.2.1 or the latest master versions.

Example:

import keras.layers as kl

test_input = kl.Input(shape=(10, 10), dtype='int32')
test_emb = kl.Embedding(input_dim=100, output_dim=10)(test_input)
test_bgru = kl.Bidirectional(kl.GRU(50, return_sequences=True))(test_emb)

This fails with TypeError: Expected int32, got <tensorflow.python.ops.variables.Variable object at 0x7f162824e588> of type 'Variable' instead. since the arguments of value and axis are switched: https://www.tensorflow.org/versions/r1.0/api_docs/python/array_ops/slicing_and_joining#concat https://www.tensorflow.org/api_docs/python/array_ops/slicing_and_joining#concat

neufang commented 7 years ago

same here.

tributeError Traceback (most recent call last) /usr/local/lib/python3.5/dist-packages/keras/backend/tensorflow_backend.py in concatenate(tensors, axis) 1424 try: -> 1425 return tf.concat_v2([to_dense(x) for x in tensors], axis) 1426 except AttributeError:

AttributeError: module 'tensorflow' has no attribute 'concat_v2'

EinsteinInIct commented 7 years ago

I met the similar problem when writing code like below:

“up6 = merge([UpSampling2D(size=(2, 2))(conv5), conv4], mode='concat', concat_axis=1)”

Seems that there are lots of api changes in new version of tensorflow according to: https://groups.google.com/a/tensorflow.org/forum/#!msg/discuss/OePXmC9kJ7o/SRErOoYCDQAJ

fchollet commented 7 years ago

Keras 2 is coming soon, so you should use that. It's developed for TF 1.0.

On 11 March 2017 at 18:41, qjin notifications@github.com wrote:

I met the similar problem when writing code like below:

“up6 = merge([UpSampling2D(size=(2, 2))(conv5), conv4], mode='concat', concat_axis=1)”

Seems that there are lots of api changes in new version of tensorflow according to: https://groups.google.com/a/tensorflow.org/forum/#!msg/ discuss/OePXmC9kJ7o/SRErOoYCDQAJ

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fchollet/keras/issues/5238#issuecomment-285917235, or mute the thread https://github.com/notifications/unsubscribe-auth/AArWb6e4MJPvFPm4thRpzH7A84nK79WYks5rk1tQgaJpZM4Lzo0n .

EinsteinInIct commented 7 years ago

Thanks for reply. I had planed to make a pull request. But I found the fix for my problem is already in the newest code.

Looking forward to embrace Keras 2 :)

stale[bot] commented 7 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.