fastbook icon indicating copy to clipboard operation
fastbook copied to clipboard

__init__.py deprecation warning for linspace usage

Open juliangilbey opened this issue 4 years ago • 1 comments

I wasn't quite sure where to report this, as __init.py__ does not actually seem to appear in this repository (only in the fastbook package).

Running the notebook for chapter 4, I got the following warning when running the plot_function cell:

/home/jdg/fast.ai.course/fastai-venv/lib/python3.9/site-packages/fastbook/__init__.py:73: UserWarning: Not providing a value for linspace's steps is deprecated and will throw a runtime error in a future release. This warning will appear only once per process. (Triggered internally at  /pytorch/aten/src/ATen/native/RangeFactories.cpp:23.)
  x = torch.linspace(min,max)

The fix is clear: add a suitable third argument to the torch.linspace invocation.

juliangilbey avatar Feb 01 '21 13:02 juliangilbey

I wasn't quite sure where to report this, as __init.py__ does not actually seem to appear in this repository (only in the fastbook package).

Running the notebook for chapter 4, I got the following warning when running the plot_function cell:

/home/jdg/fast.ai.course/fastai-venv/lib/python3.9/site-packages/fastbook/__init__.py:73: UserWarning: Not providing a value for linspace's steps is deprecated and will throw a runtime error in a future release. This warning will appear only once per process. (Triggered internally at  /pytorch/aten/src/ATen/native/RangeFactories.cpp:23.)
  x = torch.linspace(min,max)

The fix is clear: add a suitable third argument to the torch.linspace invocation.

You can find the function in the utils.py file in this repo, adding steps to it won't do much unless you explicitly import it. If the deprecation warning bothers you too much, change it on the init.py file directly and set it to a high number (number of points you would like to plot). It should not affect anything else.

This is how it is currently handled - steps=100

.. warning:: Not providing a value for :attr:steps is deprecated. For backwards compatibility, not providing a value for :attr:steps will create a tensor with 100 elements. Note that this behavior is not reflected in the documented function signature and should not be relied on. In a future PyTorch release, failing to provide a value for :attr:steps will throw a runtime error.

ghost avatar Dec 07 '21 15:12 ghost