mirror of
https://github.com/qurator-spk/sbb_pixelwise_segmentation.git
synced 2025-07-01 22:50:15 +02:00
resolving issued with saving model by steps
This commit is contained in:
parent
1454bc4f58
commit
d554d26739
1 changed files with 3 additions and 2 deletions
5
train.py
5
train.py
|
@ -21,6 +21,7 @@ class SaveWeightsAfterSteps(Callback):
|
||||||
self.save_interval = save_interval
|
self.save_interval = save_interval
|
||||||
self.save_path = save_path
|
self.save_path = save_path
|
||||||
self.step_count = 0
|
self.step_count = 0
|
||||||
|
self._config = _config
|
||||||
|
|
||||||
def on_train_batch_end(self, batch, logs=None):
|
def on_train_batch_end(self, batch, logs=None):
|
||||||
self.step_count += 1
|
self.step_count += 1
|
||||||
|
@ -31,8 +32,8 @@ class SaveWeightsAfterSteps(Callback):
|
||||||
|
|
||||||
self.model.save(save_file)
|
self.model.save(save_file)
|
||||||
|
|
||||||
with open(os.path.join(os.path.join(save_path, "model_step_{self.step_count}"),"config.json"), "w") as fp:
|
with open(os.path.join(os.path.join(self.save_path, f"model_step_{self.step_count}"),"config.json"), "w") as fp:
|
||||||
json.dump(_config, fp) # encode dict into JSON
|
json.dump(self._config, fp) # encode dict into JSON
|
||||||
print(f"saved model as steps {self.step_count} to {save_file}")
|
print(f"saved model as steps {self.step_count} to {save_file}")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue