Difference between model.parameters and model.parameters(), pytorch
I have read through the documentation and I don't really understand the explanation. Here is the explanation I got from the documentation Returns an iterator over module parameters. Why does model.parameters() return the file location e.g &lt;generator object Module.parameters at 0x7f1b90c29ad0&gt;. model.parameters will give me an output of
&lt;bound method Module.parameters of ResNet9(
  (conv1): Sequential(
    (0): Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (2): ReLU(inplace=True)
  )
  (conv2): Sequential(
    (0): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (2): ReLU(inplace=True)
    (3): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  ).....



  


model.parameters()
It's simply because it returns an iterator object, not a list or something like that. But it behaves quite similar to a list. You can iterate over it eg with
[x for x in model.parameters()]
Or you can convert it to a list
[list(model.parameters())]
Iterators have some advantages over lists. Eg they are not &quot;calculated&quot; when they are created, which can improve performance.
For more on iterators just google for &quot;python iterators&quot;, you'll find plenty of information. Eg w3schools.com is a good source.
model.parameters
The output model.parameters consists of two parts.
The first part bound method Module.parameters of tells you that you are referencing the method Module.parameters.
The second part tells you more about the object containing the referenced method. It' s the &quot;object description&quot; of your model variable. It's the same as print(model)
more on python references
model.parameter is just a reference to the parameter function, it's not executing the function. model.parameter() instead is executing it.
Maybe it gets more clear with a simple example.
print(&quot;Hello world&quot;)
&gt;&gt;&gt; Hello world
print
&gt;&gt;&gt; &lt;function print&gt;

abc = print

abc(&quot;Hello world&quot;)
&gt;&gt;&gt; Hello world
abc
&gt;&gt;&gt; &lt;function print&gt;

As you see abc behave exactly the same as print because i assigned the reference of print to abc.
If I would have executed the function instead, eg abc = print(&quot;Hello world&quot;), abc would contain the string Hello world and not the function reference to print.
