yoyololicon / pytorch-NMF

A pytorch package for non-negative matrix factorization.
https://pytorch-nmf.readthedocs.io/
MIT License
223 stars 24 forks source link

Can't run sparse_fit #7

Closed schonkopf closed 3 years ago

schonkopf commented 3 years ago

I was running sparse NMF using the following codes:

net = NMF(data.shape, rank=self.basis_num).cuda()
net.sparse_fit(data.cuda(), verbose=True, max_iter=200, beta=1, sW=0.3)

Error message occurs: /content/pytorchNMF/torchnmf/nmf.py in sparse_fit(self, V, beta, max_iter, verbose, sW, sH) 378 W.grad = None 379 WH = self.reconstruct(H.detach(), W) --> 380 loss = beta_div(self.fix_neg(WH), V, beta) 381 loss.backward() 382 with torch.no_grad():

/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py in getattr(self, name) 777 return modules[name] 778 raise ModuleAttributeError("'{}' object has no attribute '{}'".format( --> 779 type(self).name, name)) 780 781 def setattr(self, name: str, value: Union[Tensor, 'Module']) -> None:

ModuleAttributeError: 'NMF' object has no attribute 'fix_neg'

yoyololicon commented 3 years ago

Good catch! Will commit a hot fix asap.

yoyololicon commented 3 years ago

@schonkopf The new commit 92d20ce34392052f27f4ee526c1acb9f60a33261 should solve the issue.