Detach the loaded model
Is there a correct way to detach a loaded model, when we don’t need to compute its gradients ? For the moment, I’m doing that: <SCODE>model = torch.load('mymodel.pth')
for variable in model.parameters():
    variable.detach_()
<ECODE>
alexis-jacq
the correct way is to make the model’s parameters not require gradients: <SCODE>model = torch.load('mymodel.pth')
for p in model.parameters()
    p.requires_grad = False
<ECODE> <SCODE>myinput = torch.randn(10, 20) # example input
model = torch.load('mymodel.pth')
input = Variable(myinput, volatile=True)
output = model(input)
<ECODE>
smth
Ah! good point for the input! Ok, thanks a lot!
alexis-jacq
NVM - sorry I figured it out my mistake.
FuriouslyCurious