Setting weights
self.fc = nn.Linear(100, 200)
tensor_weights = torch.from_numpy(random_weights_).type(torch.FloatTensor)
param_weights = nn.Parameter(tensor_weights)
self.fc.weight = param_weights
In forward(inp)
inp = inp.view(inp.shape[0], -1)
out = self.fc(inp)
Gives error
RuntimeError: The expanded size of the tensor (100) must match the existing size (200) at non-singleton dimension 1. Target sizes: [8, 100]. Tensor sizes: [200]
print(inp.shape)
print(self.inp.weight.shape)
Outputs
torch.Size([8, 100])
torch.Size([100, 200])
What is the issue??
Thank you
P.S nevermind, random_weights_ matrix had wrong dimensions. Transpose resolved it