BoyuanJiang / matching-networks-pytorch

Matching Networks for one shot learning
228 stars 67 forks source link

How to run this model with newest pytorch? #7

Closed danzhewuju closed 10 months ago

danzhewuju commented 4 years ago

You need to change code: line 133 def repackage_hidden(self,h): """Wraps hidden states in new Variables, to detach them from their history.""" if type(h) == Variable: return Variable(h.data) else: return tuple(self.repackage_hidden(v) for v in h) to def repackage_hidden(self, h): """Wraps hidden states in new Variables, to detach them from their history.""" if isinstance(h, torch.Tensor): return h.detach() else: return tuple(self.repackage_hidden(v) for v in h) and all acc.data[0], loss.data[0] should be changed to acc.item(),loss.item().

then you can run the code with newest pytorch.