预计会看到2个数组,但获得了以下1个数组的列表

时间:2019-03-19 01:23:41

标签: tensorflow keras

我想创建一个接收一个图像并通过两个Softmax(两个输出)计算图像的模型。代码是:

base_model = InceptionV3(include_top=False)
x = base_model.output
x = GlobalAveragePooling2D()(x)

#  first softmax
x_1 = Dense(1024, activation='relu')(x)
predictions_1 = Dense(4, activation='softmax')(x_1)

#  second Softmax
x_2 = Dense(1024, activation='relu')(x)
predictions_2 = Dense(4, activation='softmax')(x_2)
my_model = Model(inputs=base_model.input, outputs=[predictions_1,predictions_2])

#  train
my_model.compile(...)
my_model.fit_generator(...)

训练时出现错误:

  

ValueError:预期会看到2个数组,但得到了以下内容   1个数组的列表:[array([[0。,0.,0.,1.],[0.,0.,0.,1.],[0.,0.,   0.,1.],[0.,1.,0.,0.],[1.,0.,0.,0.],[0.,1.,0.,0.],[ 0.,1.,0.,0.],[0.,1.,0.,0。],...

0 个答案:

没有答案