Commit 0d44104b authored by sjjsmuel's avatar sjjsmuel

remove pre-train

parent ec31a4c5
......@@ -101,49 +101,15 @@ test_dataset = test_loader.load_dataset()
network = Resnet50(n_classes, img_width, img_height, channels, resnet_file)
model = network.get_model()
#compile the model
for layer in model.layers[154:]:
layer.trainable = True
#compile the model
model.compile(optimizer=RMSprop(), loss='categorical_crossentropy', metrics=['accuracy'])
# Print Network summary
# model.summary()
'''
Pre-Train FC Layers
'''
callbacks_prefit = [
ModelCheckpoint(
filepath= str(checkpoint_path) + '/best_pre_train.hdf5',
save_best_only=True,
monitor='val_loss',
verbose=1),
EarlyStopping(monitor='val_loss', patience=10),
TensorBoard(options.output_path +'/logs/{}_prefit'.format(time)),
]
history = model.fit(train_dataset,
epochs=options.num_epochs_pre_train,
validation_data=validation_dataset,
callbacks=callbacks_prefit,
verbose=2
)
#model.save_weights('last_pre_train_model.h5')
print('\nHistory dict:', history.history)
'''
Run refinement training on best model of pre-train
'''
model = load_model(str(checkpoint_path) + '/best_pre_train.hdf5')
for layer in model.layers[154:]:
layer.trainable = True
model.compile(optimizer=SGD(lr=1e-4, momentum=0.9), loss='categorical_crossentropy', metrics=['accuracy'])
# Reload Training Data to shuffle and augment in a different way then before
train_dataset = train_loader.load_dataset()
validation_dataset = validation_loader.load_dataset()
callbacks = [
ModelCheckpoint(
filepath= str(checkpoint_path) + '/model.{epoch:03d}-{val_loss:.3f}.hdf5',
......@@ -166,7 +132,6 @@ history = model.fit(train_dataset,
callbacks=callbacks,
verbose=2
)
print('\nHistory dict:', history.history)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment