Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated usage of torch.nn.utils.weight_norm #2387

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions darts/models/forecasting/tcn_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def __init__(
)
if weight_norm:
self.conv1, self.conv2 = (
nn.utils.weight_norm(self.conv1),
nn.utils.weight_norm(self.conv2),
nn.utils.parametrizations.weight_norm(self.conv1),
nn.utils.parametrizations.weight_norm(self.conv2),
)

if input_dim != output_dim:
Expand Down
2 changes: 1 addition & 1 deletion darts/models/forecasting/torch_forecasting_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ def save(self, path: Optional[str] = None) -> None:
torch.save(self, f_out)

# save the LightningModule checkpoint
path_ptl_ckpt = path + ".ckpt"
path_ptl_ckpt = path.replace(".pt", "") + ".ckpt"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will break the logic in the load() method, I would rather not include it in this PR and discuss it in a separate issue.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed 👍 @SaeedForoutan, can you apply the changes?

if self.trainer is not None:
self.trainer.save_checkpoint(path_ptl_ckpt)
# TODO: keep track of PyTorch Lightning to see if they implement model checkpoint saving
Expand Down
Loading