将TimeDistributed应用于Keras中的InceptionResnetV2时出错

将TimeDistributed应用于Keras中的InceptionResnetV2时出错,keras,keras-layer,Keras,Keras Layer,这就是我得到的错误 x=Input(shape=(10,299,299,3)) y=TimeDistributed(InceptionResnetV2(include_top=False,weights='./weights.h5'))(x) 无法将类型的对象转换为张量。内容:(-1,10,无,无,1536)。考虑将图元强制转换为受支持的类型。 我不知道为什么会出现此错误,但可以使用以下解决方法: Failed to convert object of type <type 'tuple

这就是我得到的错误

x=Input(shape=(10,299,299,3))
y=TimeDistributed(InceptionResnetV2(include_top=False,weights='./weights.h5'))(x)
无法将类型的对象转换为张量。内容:(-1,10,无,无,1536)。考虑将图元强制转换为受支持的类型。

我不知道为什么会出现此错误,但可以使用以下解决方法:

Failed to convert object of type <type 'tuple'> to Tensor. Contents: (-1, 10, None, None, 1536). Consider casting elements to a supported type.

谢谢。这帮助我避开了那个错误。但是现在我得到了一个维度错误-
检查目标时出错:期望lambda_2有5个维度,但得到了形状为(8,1)的数组
问题是你
Y
,你想用这个模型做什么?您的模型输出
(批处理,10,8,8,1536)
,而您的
Y
(8,1)
,这些必须匹配。很抱歉,我很抱歉,我不知道错误是关于Y的。解决了我的问题您的模型必须输出
(无,1)
。。。。但是这个标签是二进制的吗?(只有两节课?)是的,只有两节课
x=Input(shape=(10,299,299,3))

#join the steps dimension with the samples dimension, the model won't see a difference    
y=Lambda(lambda x: K.reshape(x,(-1,299,299,3)))(x)

#use a regular inception model
y = InceptionResNetV2(include_top=False,weights=None)(y)

#bring back the hidden steps dimension
y = Lambda(lambda x: K.reshape(x,(-1,10,8,8,1536)))(y)