What does *variable.shape mean in python
I know "*variable_name" assists in packing and unpacking.

But how does variable_name.shape work? Unable to visualize why the second dimension is squeezed out when prefixing with ""?

print("top_class.shape {}".format(top_class.shape))
top_class.shape torch.Size([64, 1])

print("*top_class.shape {}".format(*top_class.shape))
*top_class.shape 64


for numpy.array that is extensively used in math-related and image processing programs, .shape describes the size of the array for all existing dimensions:

&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; a = np.zeros((3,3,3))
&gt;&gt;&gt; a
array([[[ 0.,  0.,  0.],
        [ 0.,  0.,  0.],
        [ 0.,  0.,  0.]],

       [[ 0.,  0.,  0.],
        [ 0.,  0.,  0.],
        [ 0.,  0.,  0.]],

       [[ 0.,  0.,  0.],
        [ 0.,  0.,  0.],
        [ 0.,  0.,  0.]]])
&gt;&gt;&gt; a.shape
(3, 3, 3)
&gt;&gt;&gt; 




The asterisk "unpacks" the tuple into several separate arguments, in your case (64,1) becomes 64, 1, so only the first one get printed because there's only one format specification.
