如下代码:
from keras.layers import Input
from keras.models import Model
.
.
.
img_input = Input(shape=input_shape_img)
roi_input = Input(shape=(None, 6))
.
.
.
model_classifier = Model([img_input, roi_input], classifier)
无论在
model_classifier.load_weights(cfg.model_path, by_name=True)
还是
loss_classifier = model_classifier.train_on_batch(X, Y)
均出现“you must feed a value for placeholder tensor 'input_2' with dtype float and shape [?,?,6]”错误。但是这里并没有定义tf.placeholder()变量,可以看到的是roi_input = Input(shape=(None, 6))。最后检查发现,只需把程序中的:
#Raise problem
ox = tf.Variable(inner_x - outer_x)
oy = tf.Variable(inner_y - outer_y)
#如上两行代码改为如下即可
ox = inner_x - outer_x
oy = inner_y - outer_y
因为tf.Variable()变量需要初始化值。
如果您觉得我的文章对您有所帮助,欢迎扫码进行赞赏!