What's the meaning of this asterisk?

In such following segment of code:


What’s the function of this asterisk here?

I have tried the code between with asterisk and without asterisk and I got the same result.


In general an asterisk is used to pack or unpack values of iterables (See here for a more general explanation). So the asterisk in this case should unpack the result c.size() into the dimension sizes of c (e. g. N, C, H, W if you’re using image data).

To get it both working I think that view either accepts an argument of type torch.Size (as returned by c.size()) or a number of integers specifying the dimension sizes (e.g. to specify the size manually without having to convert it to torch.Size before)