我正在尝试建立一个模型对我的图片进行分类(二进制),但是我遇到了这个问题,有人可以帮我解决这个问题。谢谢大家〜 这是模型,以及训练过程
def googLeNet(input = Input(shape=(224, 224, 3))):
.................
.................
...............
averagepool1_7x7_s1 = AveragePooling2D(pool_size=(7, 7), padding='same')(inception_5b)
drop1 = Dropout(rate=0.4)(averagepool1_7x7_s1)
linear = Dense(units=1, activation='linear')(drop1)
last = Dense(units=1, activation='softmax')(linear)
model = Model(input=input, outputs=last)
return model
-----------------------------------------------------------------------
train_datagen = ImageDataGenerator(rescale=1./255)
test_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(
train_dir,
target_size=(224, 224),
batch_size=20,
class_mode='binary'
)
validation_generator = test_datagen.flow_from_directory(
test_dir,
target_size=(224, 224),
batch_size=20,
class_mode='binary'
)
model = googLeNet()
model.summary()
model.compile(loss='binary_crossentropy',
optimizer=optimizers.RMSprop(lr=1e-4),
metrics=['acc']
)
history = model.fit_generator(train_generator,
steps_per_epoch=100,
epochs=30,
validation_data=validation_generator,
validation_steps=50
)