Kwargs in documentation

the documentation references kwargs -> any, but i can’t find the documentation where kwargs are listed and which apply to which function (if it varies). Can someone point me to the location in the documentation? Thanks a ton

1 Like

kwargs is a python concept and I wouldn’t expect doc to describe it

Yes kwargs are a python concept. uses the concept in its functions to allow keyword arguments to be entered into the method call.
However, it is not clear which keywords which function accepts.
cnn_learner accepts the kwarg “model_dir” from the learner class.
The function predict also accepts kwargs, but probably not the same as cnn_learner. predict has no use or concept of a model_dir, which originates in the learner object that cnn_learner creates.

So my question still stands, where can i find the corresponding kwargs allowed in a specific function call? For example predict from the vision module.
Or is there a python generic way to identify these kwargs? Then that would obviously also answer the question. Your answer sadly does not :frowning:

Did you check There you can find examples and links to test scripts as further examples

Yes i have checked (I literally started this post with “the documentation[…]”.)

cnn_learner has no tests.
And the source code from the predict test case does not show me the kwargs i can use with it.

def test_models_meta(mnist_tiny, arch, zero_image):
    learn = cnn_learner(mnist_tiny, arch, metrics=[accuracy, error_rate])
    pred = learn.predict(zero_image)
    assert pred is not None

I have the same question. How do you make out which function accepts which all kwargs?
Any explanation? I went throu docs but kwargs not explained there for all functions.

For Eg, data.show_batch(). It accepts figsize as a keyword argument. But I am not able to find where is it documented.

some methods, like ImageDataBunch.from_folder actually have a reference. This is what i expected for all methods.

Refer to create_from_ll to see all the **kwargs arguments.

kwargs get passed down to the functions used by the function you’re calling. the data.show_batch(), for example, will pass the kwargs to self.train_ds.x.show_xys() and its show_xys() that can make use of figsize. Sometimes the documentation mentions where the kwargs will go. The cnn_learner() documentation says, for example, that kwargs are passed down to Learner. I found it easier (and quite helpful anyway) to read the code to see where kwargs go. Always learn something else along the way :slight_smile:


I agree with OP - the documentation could be much clearer in letting us know what the valid kwarg options are. I’m finding this quite frustrating - appreciate some more helpful tips if anyone has any other tips