Lame
November 8, 2020, 11:15pm
#1
I’m using PyTorch for training GCN, I have a simple model that saved using this command:
torch.save(MyNet().state_dict(), PATH)
Then I load it by doing the following:
model = MyNet()
model.load_state_dict(torch.load(PATH))
model.eval()
But then when I tried to input the data as follows:
output = model(dataset)
I got this error for the previous line:
TypeError: 'NoneType' object is not callable
I don’t know what’s the reason for that, could you please help me?
ptrblck
November 9, 2020, 1:29am
#2
Could you add some debug statements to your code and check, if the model
variable was replaced somewhere?
model = MyNet()
print(model)
[...]
print(model)
output = model(dataset)
I guess that model
was initially a valid object, but might have been replaced accidentally with None
.
Lame
November 9, 2020, 2:16pm
#3
When I tried to print the model after model = MyNet()
I got the model printed well, but then when I tried to print it before output = model(dataset)
I got None
What could be the problem?
ptrblck
November 9, 2020, 9:55pm
#4
It seems your code is overwriting the model
variable at one point.
Search for all usages of model
and make sure it’s not replaced by a None
value.