我正在使用我自己的数据集微调VGG16预训练模型,该数据集有2个类别。当我尝试运行#quote_box{
background-image: url('parchment.jpg');
border: solid black;
border-radius:5px;
height:400px;
width:300px;
background-size:cover;
background-repeat: no-repeat;
box-shadow:20px 20px 10px;
display: block;
}
#quote {
margin:10%;
text-align:center;
font-size: 22px;
font-weight: bold;
font-family:Georgia;
color: black;
时,我收到此错误:
model.fit_generator()
但是output of generator should be a tuple (x, y, sample_weight) or (x, y). Found: None'.
找到了我从终端可以看到的图像。
我该如何解决这个问题?请帮助!
flow_from_directory
答案 0 :(得分:1)
对于两个班级,您的顶层似乎有误。将其更改为
x = Dense(1, activation='sigmoid', name='predictions')(x)
model = Model(base_model.input , x)
model.compile(optimizer='sgd', loss='binary_crossentropy', metrics= ['accuracy'])
我还建议您在“无头”VGG16基座上添加完整的分类器模型,就像您在Keras示例代码中看到的那样:
top_model = Sequential()
top_model.add(Flatten(input_shape=model.output_shape[1:]))
top_model.add(Dense(256, activation='relu'))
top_model.add(Dropout(0.5))
top_model.add(Dense(1, activation='sigmoid'))
https://gist.github.com/fchollet/7eb39b44eb9e16e59632d25fb3119975
您还应该从此行中删除classes
参数:
base_model = VGG16(weights=None, include_top=False, input_shape=input_shape, classes=2)
请参阅此处的VGG16应用程序的Keras文档:https://keras.io/applications/#vgg16