Beginner: Basics of fastai, PyTorch, numpy, etc ✅

If you need help getting started with the basic libraries we rely on in the course, like fastai, pytorch, numpy, matplotlib, and pandas, post your questions here!

Hi everyone, Jeremy showed a section where you could see info about the API. for example, if I want to see a list of what’s in URLs, where’s the best place to find this type of info? Many thanks

I’m guessing it’s the documentation page: https://docs.fast.ai/

4 Likes

Yes as @Gabriel_Syme mentioned, https://docs.fast.ai is the current resource. To find the list of URLs see here:
External data | fastai

3 Likes

Thanks :slight_smile:

In addition to using documentation website you can also type:

URLs??

in Jupyter nnotebook. This will print docstring and sourcecode for the URLs. Can be useful for fast exploration.

3 Likes

Very true, thanks for the tip!!

I think the datablock api bit confusing, and get_items splitter get_y get_x are not part of the constructor and an intellisense does not show those input parameters.

I don’t follow. They are part of the constructor, they appear in doc(), they’re shown in the docs, and they appear in the intellisense for me (using Jupyter Notebook).

What are you finding confusing about these parameters? Have you tried the tutorial?

2 Likes

Thank you for the response. I did not use doc function I was using control+space to call the intellisens:
image
I am going to use doc function going forward.

That’s interesting - the platform you’re using isn’t using our delegates functionality correctly, so the kwargs aren’t being shown. Instead it’s just showing **kwargs. What platform is that which you’re using there?

1 Like

n/m I figured it out - it’s Colab. I just tested, and you’re right, at first it doesn’t show all the arguments. But I noticed if I wait a couple of seconds then it does, at the bottom:

1 Like

Shravan Kumar:
​when we are running the finetuning using fine_tune(x) . is it necessary that last epoch specified should have less error metric? Until we reach this best epoch; do we need to keep on running?

So essentially you are asking when is the model best fit. The idea is the valid loss should decrease along with the training loss. The best model would be the model with the least valid loss

Generally you want to keep training until your validation loss stops improving or until you run out of time. Sometimes the last epoch does not contain the best validation loss or metric and there are methods for saving the model as training is happening automatically as long as the validation loss is improving using the SaveModelCallback.

6 Likes

Is #export app which jeremy showed just now, part of nbdev?

2 Likes

yes it is.

1 Like

Yes, when specified, will export the cells to python file

1 Like

Can some experienced users please list strategies to browse through the fastai code? I’m looking for suggestions on where to start and what are the best tools to use?

Do you recommend just cloning the repo and then grepping around (but these are ipynb files) or would it be better to load the cloned repo directory in VSCODE and use some extensions which would help in explorations (like I see some @function and I want to know what it does but instead of looking at all the imports, I just click on it and it takes me to that function?)

I’m sorry if there are obvious solutions to this, I don’t have a developer background and as much as I want to dig through the code, I’m find it a little bit overwhelming to figure out where to start as I feel I need to go deeper into every definition as I know nothing about the framework at all.

2 Likes

@mike.moloch

Few steps that worked for me during different scenarios

When I am experimenting and reproducing the notebook, I try to stick to the notebook environment itself and before using a fastai function, I run doc(FUNC_NAME) and try to understand what each parameter does. As Jeremey mentioned in the lecture ?? FUNC_NAME is your friend to read through the code.

Below is a recent discovery from rich (wrapper over python inspect module) , gives a nice summary of a module/object etc

from rich import inspect as rinspect
rinspect(OBJECT) 

When I need to understand a module, I typically use docs.fast.ai and it has source linked from the docs. I also clone fastai repo to my local and use vscode to jump around the fastai module. Make sure you also clone fastcore since lots of goodies from this library are used in fastai library.

9 Likes

Thanks @msivanes , I really like the rinspect() function, this is exactly the kind of thing I was looking for.

I do try to lookup functions used in a lesson notebook via doc() and ?? , but sometimes there’s this rabbithole you need to descend into and it’s hard to figure out at what abstraction level one should remain. I thought maybe I’d start with the tutorials section but I’ve also seen advice on reading through the library code to understand what might actually be going on. So the rich.inspect() functionality would come in super handy!

Cheers!