titu1994 / Inception-v4

Inception-v4, Inception - Resnet-v1 and v2 Architectures in Keras
MIT License
385 stars 172 forks source link

TypeError: Expected int32, got list containing Tensors of type '_Message' instead. #4

Closed MartinThoma closed 7 years ago

MartinThoma commented 7 years ago

When I execute

#!/usr/bin/env python

import tensorflow as tf
from inception_v4 import create_inception_v4

model = create_inception_v4()

I get

$ python test.py
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
Using TensorFlow backend.
Traceback (most recent call last):
  File "test.py", line 6, in <module>
    model = create_inception_v4()
  File "/home/moose/GitHub/Inception-v4/inception_v4.py", line 190, in create_inception_v4
    x = inception_stem(init)
  File "/home/moose/GitHub/Inception-v4/inception_v4.py", line 45, in inception_stem
    x = merge([x1, x2], mode='concat', concat_axis=channel_axis)
  File "/home/moose/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 1680, in merge
    name=name)
  File "/home/moose/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 1301, in __init__
    self.add_inbound_node(layers, node_indices, tensor_indices)
  File "/home/moose/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 635, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/home/moose/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 172, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors, mask=input_masks))
  File "/home/moose/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 1394, in call
    return K.concatenate(inputs, axis=self.concat_axis)
  File "/home/moose/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 1427, in concatenate
    return tf.concat(axis, [to_dense(x) for x in tensors])
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 1047, in concat
    dtype=dtypes.int32).get_shape(
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 651, in convert_to_tensor
    as_ref=False)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 716, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py", line 176, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py", line 165, in constant
    tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 367, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 302, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

Environment

$ python -c "import tensorflow;print(tensorflow.__version__)"
1.0.0

CUDA 8, CuDNN 5.1, Titan Black

MartinThoma commented 7 years ago

I've upgraded to Keras 1.2.2. Now I get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "inception_v4.py", line 215, in create_inception_v4
    x = Flatten()(x)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 572, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 635, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 166, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
  File "/usr/local/lib/python2.7/dist-packages/keras/layers/core.py", line 483, in call
    return K.batch_flatten(x)
  File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 1629, in batch_flatten
    x = tf.reshape(x, tf.pack([-1, prod(shape(x)[1:])]))
AttributeError: 'module' object has no attribute 'pack'

pack has been renamed to stack in Tensorflow 1.0 (source1, source2)

After replacing pack by stack in /usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py line 1629 it worked.