python - PyTorch: What's the difference between state_dict ...
stackoverflow.com › questions › 54746829Feb 18, 2019 · The parameters () only gives the module parameters i.e. weights and biases. Returns an iterator over module parameters. You can check the list of the parameters as follows: for name, param in model.named_parameters (): if param.requires_grad: print (name) On the other hand, state_dict returns a dictionary containing a whole state of the module. Check its source code that contains not just the call to parameters but also buffers, etc.
Parameter — PyTorch 1.10.1 documentation
pytorch.org › torchParameter. class torch.nn.parameter.Parameter(data=None, requires_grad=True) [source] A kind of Tensor that is to be considered a module parameter. Parameters are Tensor subclasses, that have a very special property when used with Module s - when they’re assigned as Module attributes they are automatically added to the list of its parameters, and will appear e.g. in parameters () iterator.
Module — PyTorch 1.10.1 documentation
pytorch.org › docs › stableThe parameter can be accessed as an attribute using given name. Parameters. name (string) – name of the parameter. The parameter can be accessed from this module using the given name. param (Parameter or None) – parameter to be added to the module. If None, then operations that run on parameters, such as cuda, are ignored.