Python Keras:“;TypeError:应为int32,获取包含类型为'的张量的列表_消息';相反。”;

Python Keras:“;TypeError:应为int32,获取包含类型为'的张量的列表_消息';相反。”;,python,python-3.x,tensorflow,keras,Python,Python 3.x,Tensorflow,Keras,我正试图在Keras中训练一个LSTM模型,我发现了上面的错误。以下内容再现了该错误: from keras.layers import LSTM from keras.models import Sequential model = Sequential() model.add(LSTM(128, input_shape=(1000,1000))) 我正在使用Python 3.4、Keras 2.0.4和TensorFlow后端版本0.12.1 以下是回溯: File "test.p

我正试图在Keras中训练一个LSTM模型,我发现了上面的错误。以下内容再现了该错误:

from keras.layers import  LSTM
from keras.models import Sequential

model = Sequential()
model.add(LSTM(128, input_shape=(1000,1000)))
我正在使用Python 3.4、Keras 2.0.4和TensorFlow后端版本0.12.1

以下是回溯:

  File "test.py", line 6, in <module>
    model.add(LSTM(128, input_shape=(1000,1000)))
  File "/usr/local/lib/python3.4/dist-packages/keras/models.py", line 433, in add
    layer(x)
  File "/usr/local/lib/python3.4/dist-packages/keras/layers/recurrent.py", line 243, in __call__
    return super(Recurrent, self).__call__(inputs, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/keras/engine/topology.py", line 558, in __call__
    self.build(input_shapes[0])
  File "/usr/local/lib/python3.4/dist-packages/keras/layers/recurrent.py", line 1012, in build
    constraint=self.bias_constraint)
  File "/usr/local/lib/python3.4/dist-packages/keras/legacy/interfaces.py", line 88, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/keras/engine/topology.py", line 391, in add_weight
    weight = K.variable(initializer(shape), dtype=dtype, name=name)
  File "/usr/local/lib/python3.4/dist-packages/keras/layers/recurrent.py", line 1004, in bias_initializer
    self.bias_initializer((self.units * 2,), *args, **kwargs),
  File "/usr/local/lib/python3.4/dist-packages/keras/backend/tensorflow_backend.py", line 1681, in concatenate
    return tf.concat([to_dense(x) for x in tensors], axis)
  File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/array_ops.py", line 1075, in concat
    dtype=dtypes.int32).get_shape(
  File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/ops.py", line 669, in convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/usr/local/lib/python3.4/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/python3.4/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/python3.4/dist-packages/tensorflow/python/framework/tensor_util.py", line 367, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "/usr/local/lib/python3.4/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.
文件“test.py”,第6行,在
添加(LSTM(128,输入_形=(10001000)))
文件“/usr/local/lib/python3.4/dist-packages/keras/models.py”,第433行,添加
层(x)
文件“/usr/local/lib/python3.4/dist-packages/keras/layers/recurrent.py”,第243行,在调用中__
返回超级(循环,自).\u调用(输入,**kwargs)
文件“/usr/local/lib/python3.4/dist-packages/keras/engine/topology.py”,第558行,在调用中__
自我构建(输入形状[0])
文件“/usr/local/lib/python3.4/dist-packages/keras/layers/recurrent.py”,第1012行,内部版本
约束=自身偏差(约束)
文件“/usr/local/lib/python3.4/dist-packages/keras/legacy/interfaces.py”,第88行,在包装器中
返回函数(*args,**kwargs)
文件“/usr/local/lib/python3.4/dist-packages/keras/engine/topology.py”,第391行,添加重量
weight=K.variable(初始值设定项(形状),dtype=dtype,name=name)
文件“/usr/local/lib/python3.4/dist packages/keras/layers/recurrent.py”,第1004行,在bias\u初始值设定项中
自我偏差\初始值设定项((自我单位*2,),*args,**kwargs),
文件“/usr/local/lib/python3.4/dist packages/keras/backend/tensorflow_backend.py”,第1681行,串联
返回tf.concat([到x张量中x的密度(x)],轴)
concat中的文件“/usr/local/lib/python3.4/dist packages/tensorflow/python/ops/array_ops.py”,第1075行
dtype=dtypes.int32)。获取形状(
文件“/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/ops.py”,第669行,在convert_-to_-tensor中
ret=conversion\u func(值,dtype=dtype,name=name,as\u ref=as\u ref)
文件“/usr/local/lib/python3.4/dist packages/tensorflow/python/framework/constant_op.py”,第176行,在_constant_tensor_conversion_函数中
返回常量(v,dtype=dtype,name=name)
文件“/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/constant_op.py”,第165行,常量
tensor_util.make_tensor_proto(值,dtype=dtype,shape=shape,verify_shape=verify_shape))
文件“/usr/local/lib/python3.4/dist packages/tensorflow/python/framework/tensor\u util.py”,第367行,在make\u tensor\u proto中
_资产可兼容(值、数据类型)
文件“/usr/local/lib/python3.4/dist packages/tensorflow/python/framework/tensor_util.py”,第302行,在_AssertCompatible中
(dtype.name、repr(不匹配)、type(不匹配)。\uu name
TypeError:应为int32,但得到了包含“\u Message”类型张量的列表。
我看到一些人报告了同样的问题,例如。似乎需要切换的
concat
函数有问题,但在这里它已经是正确的形式了


你知道这是什么原因吗?

只是出于好奇,你试过降低数字吗?试着(3,2)检查一下……也许你有一个TensorFlow的前沿版本。我会先尝试更新TensorFlow。啊,是的,将TensorFlow更新到1.1.0成功了。出于某种原因,我有一个旧版本,即使我今天安装了它也没有意识到。谢谢