You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Daniel, your YouTube course is 100% awesome!
Learning a lot and enjoying it.
Had a quick comment on 01-pytorch_workflow loss curve plotting. When you were showing the loss curve plotting error that occurred while plotting the graph, you converted the values from tensor to numpy arrays to fix the problem. As I was following you I stopped the video when the error occurred and tried to fix it before you showed how. I tried using 'with torch.inference_mode():' before plotting and that seemed to work.
error
[/usr/local/lib/python3.10/dist-packages/torch/_tensor.py](https://localhost:8080/#) in __array__(self, dtype)
1028 return handle_torch_function(Tensor.__array__, (self,), self, dtype=dtype)
1029 if dtype is None:-> 1030 return self.numpy()
1031 else:
1032 return self.numpy().astype(dtype, copy=False)
RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.
worked fine with use of torch.inference_mode()
# Plot the loss curveswithtorch.inference_mode(): # turn off gradient decline function before plotting graphplt.plot(epoch_count, train_loss_values, label="Train loss")
plt.plot(epoch_count, test_loss_values, label="Test loss")
plt.title("training and test loss curves")
plt.ylabel("Loss")
plt.xlabel("epoch count")
plt.legend();
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Daniel, your YouTube course is 100% awesome!
Learning a lot and enjoying it.
Had a quick comment on 01-pytorch_workflow loss curve plotting. When you were showing the loss curve plotting error that occurred while plotting the graph, you converted the values from tensor to numpy arrays to fix the problem. As I was following you I stopped the video when the error occurred and tried to fix it before you showed how. I tried using 'with torch.inference_mode():' before plotting and that seemed to work.
error
worked fine with use of
torch.inference_mode()
Beta Was this translation helpful? Give feedback.
All reactions