Later joiner here, how does this study group runs?
Hi @nok! You can read the initial wiki post and follow through the discussion to get a rough idea of how things are going to work. If you have any specific doubts feel free to ask them here.
So it will be studying the FastGarden and blog individually?
Yes, for first week that is the plan
Hi,
I may be asking some basic questions but would help if someone can answer the below queries.
- Is cls equivalent to calling self in a function?
- What is the purpose of decorator @classmethod being referenced in from_name_func function as there is no mention of it in DataLoaders or ImageDataLoaders? (I have referred this URL to understand decorators - https://www.geeksforgeeks.org/decorators-in-python/) . Calling doc of classmethod only returns ’
classmethod.__func__
’ which means it returns the original function object. - doc(using_attr) provides a link and detail of the function. The link ‘Show in docs’ navigates to https://fastcore.fast.ai/utils#using_attr. This page does not have the definition of using_attr. Am I missing something?
@classmethod
def from_name_func(cls, path, fnames, label_func, **kwargs):
"Create from the name attrs of fnames
in path
s with label_func
"
f = using_attr(label_func, ‘name’)
return cls.from_path_func(path, fnames, f, **kwargs)
Class methods are used in OOP’s to change some properties of the class itself, in this case ImageDataLoaders.
Classmethods inherits underlying properties of the class, unlike a static method that works with the parameters provided to it on its instance. Hopefully, this tutorial will help!
using_attr creates a partial function of the function passed with the specific attribute instead of the default. From what I have seen its used to get the name attribute from path files as shown in the example below…
Thanks the video was very useful.
Yes, this is understood. Thanks.
I had a query on the usage of the doc function on using_attr function. It displays the details of the function with a link. If you click the link ‘Show in docs’, it opens a page with the URL i have provided. I cant seem to find the function on that link.
Yup! Corey Schafers tutorials is the reason i’m even remotely decent at using python! His videos are pretty damn good!
After you type doc(function) click on source on the top right. That should get you the exact underlying code!
I understand what he is talking about, it’s underlying code is only in part of one function and that is from_name_func
. Give me a moment to try to trace it. You’re not going crazy @ganesh.bhat (to understand what I mean, look at the vision.data notebook, it only shows up once)
I get the below error if I click on source on the top right of the doc function output.
Blocked by Content Security Policy
An error occurred during a connection to github.com.
Firefox prevented this page from loading in this way because the page has a content security policy that disallows it.
Yup I’m trying to source where _using_attr
is coming from now as I’m curious
Wow! Great job! (how did you figure that one out?)
Couldn’t for the life of me find that! Spent an hour looking for it in the morning!
Hey all!
Maybe I’m crazy, but doing a using_attr?? in notebooks shows me:
Signature: using_attr(f, attr)
Source:
def using_attr(f, attr):
"Change function `f` to operate on `attr`"
return partial(_using_attr, f, attr)
File: /my_random_path/fastcore/fastcore/utils.py
Type: function
The File part is key.
If you open up that file, the first line tells you the notebook it came from:
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/02_utils.ipynb (unless otherwise specified).
And in the actual code, _using_attr
is right above using_attr
.
I looked at the source core by looking at using_attr??
it said the function is imported from fastcore/utils.py
so I went to github page of the fastcore library and went straight into nbs folder
(which learnt from you that nbs folders has the source notebooks ). Since it has a notebook named utils
I opened it. Pretty straightforward.