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

05_linear_regression #1

Closed
ys7yoo opened this issue May 3, 2019 · 3 comments

Comments

Projects
None yet
1 participant
@ys7yoo
Copy link
Owner

commented May 3, 2019

/usr/local/lib/python3.6/dist-packages/torch/nn/_reduction.py:49: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.
  warnings.warn(warning.format(ret))
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-2-f85695c5ca83> in <module>()
     38     # Compute and print loss
     39     loss = criterion(y_pred, y_data)
---> 40     print(epoch, loss.data[0])
     41 
     42     # Zero gradients, perform a backward pass, and update the weights.

IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
@ys7yoo

This comment has been minimized.

Copy link
Owner Author

commented May 3, 2019

fixed print(epoch, loss.data[0]) to print(epoch, loss.item())

@ys7yoo

This comment has been minimized.

Copy link
Owner Author

commented May 3, 2019

Error is gone.
But, still have a warning

/usr/local/lib/python3.6/dist-packages/torch/nn/_reduction.py:49: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.
  warnings.warn(warning.format(ret))
@ys7yoo

This comment has been minimized.

Copy link
Owner Author

commented May 3, 2019

replaced

criterion = torch.nn.MSELoss(size_average=False)

with

criterion = torch.nn.MSELoss(reduction='sum')

@ys7yoo ys7yoo closed this May 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.