Skip to content

Commit d302287

Browse files
author
Colin Grambow
committed
Save architecture and weights separately
1 parent e65e588 commit d302287

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

reacdiff/train/train.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,20 @@ def train(crnn, data, save_dir,
3434
crnn.rnn.summary()
3535
crnn.model.summary()
3636

37-
model_name = 'model.{epoch:03d}.h5'
37+
model_name = 'model.json'
38+
weights_name = 'weights.h5'
3839
model_path = os.path.join(save_dir, model_name)
40+
weights_path = os.path.join(save_dir, weights_name)
41+
with open(model_path, 'w') as f:
42+
f.write(crnn.model.to_json())
3943

4044
def lr_schedule(epoch, _):
4145
return lr_start * ((lr_end / lr_start) ** (epoch / epochs))
4246

43-
checkpoint = keras.callbacks.ModelCheckpoint(filepath=model_path,
47+
checkpoint = keras.callbacks.ModelCheckpoint(filepath=weights_path,
4448
verbose=1,
45-
save_best_only=True)
49+
save_best_only=True,
50+
save_weights_only=True)
4651
early_stopping = keras.callbacks.EarlyStopping(patience=patience,
4752
verbose=1,
4853
restore_best_weights=True)

0 commit comments

Comments
 (0)