Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Deprecation warnings migrating to 0.4 #21

Open
paulhendricks opened this issue Jul 24, 2018 · 0 comments
Open

Deprecation warnings migrating to 0.4 #21

paulhendricks opened this issue Jul 24, 2018 · 0 comments

Comments

@paulhendricks
Copy link
Contributor

paulhendricks commented Jul 24, 2018

We see the following deprecation warnings when using PyTorch Version 0.4.0 with the DeepRecommender package. These deprecation warnings will result in errors in PyTorch Version 0.5.0. Specifically, the migration involves two changes:

  • Changing nn.init.xavier_uniform to nn.init.xavier_uniform_,
  • Instead of using loss.data[0] syntax, use loss.item().

These changes are breaking; when using PyTorch Version 0.3.0, nn.init.xavier_uniform_ and loss.item() result in AttributeError: module 'torch.nn.init' has no attribute 'xavier_uniform_' and 'Variable' object has no attribute 'item' , respectively.

Deprecation warnings:

DeepRecommender/reco_encoder/model/model.py:60: UserWarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xavier_uniform_.
  weight_init.xavier_uniform(w)

DeepRecommender/reco_encoder/model/model.py:72: UserWarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xavier_uniform_.
  weight_init.xavier_uniform(w)

DeepRecommender/run.py:198: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
  t_loss += loss.data[0]
[0,     0] RMSE: 3.8345311

DeepRecommender/run.py:212: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
  total_epoch_loss += loss.data[0]

DeepRecommender/run.py:74: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
  total_epoch_loss += loss.data[0]

DeepRecommender/run.py:75: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
  denom += num_ratings.data[0]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant