sorry for my stupid question,
but i get this error:
import torch
import torch.nn as nn
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(3,3, 3)
K = torch.Tensor([[1 ,0, -1],[2, 0 ,-2], [1, 0 ,-1]])
# I think I should make the shape/size like this?
K = torch.unsqueeze(torch.unsqueeze(K,0),0)
with torch.no_grad():
self.conv1.weight = K
def forward(self, x):
x = self.conv1(x)
return x
net = Net()
net(rand(4,3,10,10))
TypeError: cannot assign 'torch.FloatTensor' as parameter 'weight' (torch.nn.Parameter or None expected)