This works fine for me. Maybe something changed accidentally in the definition of plot_function? You can check plot_function?? from a notebook cell, it should be:
def plot_function(f, title=None, min=-2.1, max=2.1, color='r', ylim=None):
x = torch.linspace(min,max, 100)[:,None]
if ylim: plt.ylim(ylim)
plt.plot(x, f(x), color)
if title is not None: plt.title(title)
or try to run a fresh copy of the notebook and see if it still gives that error.
def plot_function(f, tx=None, ty=None, title=None, min=-2, max=2, figsize=(6,4)):
x = torch.linspace(min,max, 100)
fig,ax = plt.subplots(figsize=figsize)
ax.plot(x,f(x))
if tx is not None: ax.set_xlabel(tx)
if ty is not None: ax.set_ylabel(ty)
if title is not None: ax.set_title(title)
Ok, it seems like you are using the 2020 version of the course. The current version uses a different plot_function which I was refering to (and which has the y_limit parameter), maybe there was a mixup. You can find the current course here and the function in particular in notebook 04. Does this solve you problem?
Thanks for your help @benkarr , I had the same issue as @mohitmishra . It seems we just had that function imported from fastbook. I wonder weather we should send a PR updating the function there to the one used in the course lectures.