How load neurnet? I need args and kwargs

I need args and kwargs for load model. But how can I know these parameters? Sorry if this is a strange question. But I don’t know the answer. I am downloading a MIDAS model from this source MiDaS. And I save it to a file. But to get a model, I need to create a model with parameters that I don’t know. Help?!)


I looked at the parameters in

class MidasNet(BaseModel):
    def __init__(self, path=None, features=256, non_negative=True):

And indicated them when creating the model. In this model, I want to load a saved network. the path was not copied.

But I got an error.

Error (s) in loading state_dict for Model:
Unexpected key (s) in state_dict: “pretrained.model.cls_token”, “pretrained.model.pos_embed”, …

And then there are a lot of, as I understand it, network settings that I did not specify. What should I do? Can you tell me ?!)

Hey, I’m just a programming enthusiast, but, from what I know, **kwargs usually is an optional argument passed in a dictionary form(the **dictionary is a short way of saying “for each A key in dictionary, use its values”). For example, you can use function(args, dict(learning_rate=3)). Usually, you won’t be using **kwargs that much and your code will still be fine with default parameters.
Args is the arguments which are mandatory for that function.

Example: In the documentation, you can see that the function is , f , pickle_module=pickle , pickle_protocol=DEFAULT_PROTOCOL , _use_new_zipfile_serialization=True). The args, in this case, are the object and f, which you MUST pass into the function. The other arguments are optional.

You probably need to check the code used to load the model in your class MidasNet, so you can see how it works and which args are mandatory.

From what I see in both and torch.load functions docs and from my experience, the settings are already included in your state_dict(which is a dictionary with parameters and weights for your model, saved when you use