pytorch nn.Module.parameters

返回模型的parameters的迭代对象。

1.应用

>>> for param in model.parameters():
>>>     print(type(param), param.size())
<class 'torch.Tensor'> (20L,)
<class 'torch.Tensor'> (20L, 1L, 5L, 5L)

API

parameters(recurse: bool = True) → Iterator[torch.nn.parameter.Parameter]
参数 描述
Parameters recurse (bool) if True, then yields parameters of this module and all submodules. Otherwise, yields only parameters that are direct members of this module.

参考:
https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.parameters

你可能感兴趣的:(Python,python)