save and load model
thuliyt12 opened this issue · 2 comments
Hi, i am trying to use your model to do some speaker verification experiment. After training, the model parameters are stored as below:
torch.save(Model.state_dict(),PATH)
loaded as below:
Model.load_state_dict(torch.load(PATH))
her comes the error:
AttributeError: 'Variable' object has no attribute 'copy_'
this is because state saves tdnn.context, which is a 'variable', into state_dict. When load the state_dict, variable has no attribute 'copy_'
How do you solve this problem?
Hi! Thanks for pointing that out.
It's possible that changing the line #21:
self.register_buffer('context',Variable(torch.LongTensor(context)))
to
self.register_buffer('context',torch.LongTensor(context))
might work. I haven't tested it out but it seems like self.context doesn't need to be a Variable.
I believe the issue should be fixed now so I'm gonna go ahead and close it. Please feel free to reopen if you find another..... issue 😆