当我尝试在 TimeDistributed 包装器中使用 Inception 时,我在 Keras 中遇到了一个非常奇怪的错误。
这段代码很简单,应该适用于许多模型或层,但奇怪的是,inception_v3
在预测时失败:
import numpy as np
from keras.applications import inception_v3
from keras.layers import *
from keras.models import Model
imgShape = (299,299,3)
seqShape = (2,299,299,3)
incept = inception_v3.InceptionV3(weights=None, include_top=False)
inputs = Input(seqShape)
outputs = TimeDistributed(incept)(inputs)
model = Model(inputs,outputs)
一切都很完美,直到我尝试预测某些事情:
pred = model.predict(np.ones((1,2,299,299,3)))
错误是:
InvalidArgumentError(请参阅上面的回溯):您必须使用 dtype bool 为占位符张量“batch_normalization_1/keras_learning_phase”提供一个值
[[节点:batch_normalization_1/keras_learning_phase = Placeholderdtype=DT_BOOL,shape=,_device =“/job:localhost/replica:0/task:0/device:CPU:0”]]
有什么解决办法吗?
Using Keras 2.1.0
and Tensorflow 1.4.0
.