Can't pass Value to Data Fill (New to Pytorch)

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)

Hi @jmandivarapu1
Based on what I understand, method Tensor.fill_(val) intends to let you fill tensors with a certain value, just like numpy.zeros() (I’m not totally sure about this). But in your example, net.conv1.weight[0].data.fill_(1.0) will certainly fill net.conv1.weight[0] with all 1.

To modify the weight of your model partially or fully, load_state_dict should do the trick for you:
http://pytorch.org/docs/master/nn.html?highlight=load_state_dict#torch.nn.Module.load_state_dict