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

时间:2018-03-13 09:47:55

标签: keras keras-layer

x=Input(shape=(10,299,299,3))
y=TimeDistributed(InceptionResnetV2(include_top=False,weights='./weights.h5'))(x)

这是我得到的错误

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

1 个答案:

答案 0 :(得分: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)