Hi @ptrblck_de, so what’s the solution when we use a rewrapping of a tensor via torch.flatten().
For example model is a deep conv net and at the penualtimate layer, I want to flatten the 4-d volume (B, Cout, H, W) to a 2-d tensor of size (B, CoutHW) so that i can feed it to a nn.linear layer of size (CoutHW, nClasses).
I’m getting grad none for the linear layer (fc1 below) as in the forward function I do.
forward():
…
#x4 is the out of a conv layer of size (B, Cout, H, W)
x4 = torch.flatten(x4)
x5= self.fc1(x4) # where self.fc1 =nn.Linear( CoutHW, nClasses)
I jave tried x4 =x4.view(B,-1) and this also gave the same error that grad =None for the fc1 layer.