Hi,
I am trying to modify the weight of one unit in Neural Network.
Simple updates are working fine like net.conv1.weight[0].data.fill_(1),net.conv1.weight[0].data.fill_(0)
But
Diffrent things like updating it with special array values not working.
Can anybody let me know workaround or solution for this?
print(net.conv1.weight[0])
b=(net.conv1.weight[0]).data.numpy()
ipt = torch.from_numpy(b)
ipt = b.astype(float)
#print(ipt)
net.conv1.weight[0].data.fill_(ipt)
TypeError Traceback (most recent call last)
in ()
4 ipt = b.astype(float)
5 #print(ipt)
----> 6 net.conv1.weight[0].data.fill_(ipt)
TypeError: fill_ received an invalid combination of arguments - got (numpy.ndarray), but expected (float value)
But i dont know how to create float value of this shape from numpy to torch float still not working.
Tried this
print(net.conv1.weight[0])
b=(net.conv1.weight[0]).data.numpy()
ipt = torch.from_numpy(b).float()
net.conv1.weight[0].data.fill_(ipt)
TypeError: fill_ received an invalid combination of arguments - got (torch.FloatTensor), but expected (float value)