Skip to content

Notebook 03: Different shape outputs between PyTorch 1.10, 1.11, 1.12 #71

@mrdbourke

Description

@mrdbourke

Hi all,

With the pytorch version 1.11 (and 1.12), the trick that Daniel uses (hidden_units*7*7) doesn;'t work. It worked I believe because the output in 1.10 of Conv_layer_2 =[1,10,7,7]. Multiplying each unit 10*7*7 = 490 and delivers [1,490] and thus solving this by using hidden_units*7*7 works in 1.10.

In 1.11 and 1.12, the output of conv_layer_2 is however is [10, 7, 7], leading to 7*7 and a size of [10*49]. Hence, you cannot solve the input by doing hidden*7*7 (results in 490) but rather, simply 7*7.

thus the linear layer becomes:

nn.Linear(in_features=7*7, out_features=output_shape)

Using this the shapes match and it will work on a single image,

Yet when training you will need the hidden*7*7 setup as it wont work otherwise.

Originally posted by @aronvandepol in #68

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions