Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cl0ver012 committed May 22, 2018
1 parent f231e30 commit 2a5effc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
Binary file added history/2018-05-21 21-44-41.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 17 additions & 18 deletions train_final.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,30 @@ def on_epoch_end(self, epoch, logs=None):
self.model_to_save.save(fmt % (epoch, logs['val_loss']))


pretrained_path = 'models/final.02-0.0568.hdf5'
num_gpu = len(get_available_gpus())
if num_gpu >= 2:
with tf.device("/cpu:0"):
# Load our model, added support for Multi-GPUs
encoder_decoder = build_encoder_decoder()
final = build_refinement(encoder_decoder)
final.load_weights(pretrained_path)

final = multi_gpu_model(final, gpus=num_gpu)
# rewrite the callback: saving through the original model and not the multi-gpu model.
model_checkpoint = MyCbk(final)
else:
# Load our model, added support for Multi-GPUs
encoder_decoder = build_encoder_decoder()
final = build_refinement(encoder_decoder)
final.load_weights(pretrained_path)
pretrained_path = 'models/final.61-0.0459.hdf5'
# num_gpu = len(get_available_gpus())
# if num_gpu >= 2:
# with tf.device("/cpu:0"):
# # Load our model, added support for Multi-GPUs
# encoder_decoder = build_encoder_decoder()
# final = build_refinement(encoder_decoder)
# final.load_weights(pretrained_path)
#
# final = multi_gpu_model(final, gpus=num_gpu)
# # rewrite the callback: saving through the original model and not the multi-gpu model.
# model_checkpoint = MyCbk(final)
# else:
encoder_decoder = build_encoder_decoder()
final = build_refinement(encoder_decoder)
final.load_weights(pretrained_path)

# finetune the whole network together.
for layer in final.layers:
layer.trainable = True

nadam = keras.optimizers.Nadam(lr=0.0002)
# sgd = SGD(lr=1e-4, decay=1e-6, momentum=0.9, nesterov=True)
decoder_target = tf.placeholder(dtype='int32', shape=(None, None, None, None))
decoder_target = tf.placeholder(dtype='float32', shape=(None, None, None, None))
final.compile(optimizer=nadam, loss=custom_loss, target_tensors=[decoder_target])

print(final.summary())
Expand Down

0 comments on commit 2a5effc

Please sign in to comment.