Computational Physics, Python, Linear Algebra, Svd, Code.
requires_grad=True) v=vectors_tfidf.todense() t_vectors = torch.Tensor(v.astype(np.float32)) mu = 1e-5 def grads_t(M, W, H): R = W.mm(H)-M return (R.mm(H.t()) + penalty_t(W, mu)*lam, W.t().mm(R) + penalty_t(H, mu)*lam) # dW, dH def penalty_t(M, mu): return (M<mu).type(tc.FloatTensor)*torch.clamp(M