我正在尝试适应
Keras MNIST Siamese example
使用发电机。
上
example
我们有:
model.fit([tr_pairs[:, 0], tr_pairs[:, 1]], tr_y,
batch_size=128,
epochs=epochs,
validation_data=([te_pairs[:, 0], te_pairs[:, 1]], te_y))
为了找出发电机需要返回的形状,我做到了:
np.array([tr_pairs[:, 0], tr_pairs[:, 1]]).shape
并且得到
(2, 108400, 28, 28)
然后我的发电机会返回这个:
(data, labels) = my_generator
data.shape
(2, 6, 300, 300, 3)
labels.shape
(6,)
所以,它是两个数组(用于nn输入),有6个图像(批量大小)大小
300x300x3
(RGB)。
下面是
fit_generator()
用途:
...
input_shape = (300, 300, 3)
...
model.fit_generator(kbg.generate(set='train'),
steps_per_epoch=training_steps,
epochs=1,
verbose=1,
callbacks=[],
validation_data=kbg.generate(set='test'),
validation_steps=validation_steps,
use_multiprocessing=False,
workers=0)
我想我是用同样的形状喂神经网络,但我得到了以下错误:
ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 2 array(s), but instead gotthe following list of 1 arrays: [array([[[[[0.49803922, 0.48235294, 0.55686275],
[0.63137255, 0.61176471, 0.64313725],
[0.8627451 , 0.84313725, 0.84313725],
...,
[0.58823529, 0.64705882, 0.631...
怎么了?