Skip to content

Commit

Permalink
feat(train): add option to name ckpts by epochs (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
34j authored Apr 16, 2023
1 parent 22fa277 commit bba24c4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"win_lengths": [300, 600, 120],
"window": "hann_window",
"num_workers": 4,
"log_version": 0
"log_version": 0,
"ckpt_name_by_step": false,
"accumulate_grad_batches": 1
},
"data": {
"training_files": "filelists/44k/train.txt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"port": "8001",
"keep_ckpts": 3,
"num_workers": 4,
"log_version": 0
"log_version": 0,
"ckpt_name_by_step": false,
"accumulate_grad_batches": 1
},
"data": {
"training_files": "filelists/44k/train.txt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"port": "8001",
"keep_ckpts": 3,
"num_workers": 4,
"log_version": 0
"log_version": 0,
"ckpt_name_by_step": false,
"accumulate_grad_batches": 1
},
"data": {
"training_files": "filelists/44k/train.txt",
Expand Down
6 changes: 4 additions & 2 deletions src/so_vits_svc_fork/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,16 @@ def validation_step(self, batch, batch_idx):
self.optim_g,
self.learning_rate,
self.current_epoch + 1, # prioritize prevention of undervaluation
Path(self.hparams.model_dir) / f"G_{self.total_batch_idx}.pth",
Path(self.hparams.model_dir)
/ f"G_{self.total_batch_idx if self.hparams.train.get('ckpt_name_by_step', False) else self.current_epoch + 1}.pth",
)
utils.save_checkpoint(
self.net_d,
self.optim_d,
self.learning_rate,
self.current_epoch + 1,
Path(self.hparams.model_dir) / f"D_{self.total_batch_idx}.pth",
Path(self.hparams.model_dir)
/ f"D_{self.total_batch_idx if self.hparams.train.get('ckpt_name_by_step', False) else self.current_epoch + 1}.pth",
)
keep_ckpts = self.hparams.train.get("keep_ckpts", 0)
if keep_ckpts > 0:
Expand Down

0 comments on commit bba24c4

Please sign in to comment.