Skip to content

Commit e71e2f9

Browse files
Dong Zhouyou-n-g
authored andcommitted
fix tra when logdir is None
1 parent da1f4db commit e71e2f9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

qlib/contrib/model/pytorch_tra.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ def _fit(self, train_set, valid_set, test_set, evals_result, start_epoch=0, is_p
352352
"model": copy.deepcopy(self.model.state_dict()),
353353
"tra": copy.deepcopy(self.tra.state_dict()),
354354
}
355-
torch.save(best_params, self.logdir + "/model.bin")
355+
if self.logdir is not None:
356+
torch.save(best_params, self.logdir + "/model.bin")
356357
else:
357358
stop_rounds += 1
358359
if stop_rounds >= self.early_stop:

0 commit comments

Comments
 (0)