Esempio n. 1
0
File: pmf.py Progetto: Ant1ng2/nums
    def update(self):
        for i in range(self.n_users):
            q = self.R[i, :] > 0
            V_j = self.V[:, q]

            Q = nps.matmul(V_j, V_j.T) + self.lambda_U * nps.identity(self.n_dims)
            QQ = _instance().inv(Q)

            Y = self.R[:, q][i, :]
            YY = nps.matmul(Y, V_j.T)

            self.U[:, i] = nps.matmul(QQ, YY)
def test_eye(nps_app_inst):
    import nums.numpy as nps

    assert nps_app_inst is not None

    eyes = [
        (10, 10),
        (7, 10),
        (10, 13),
    ]
    for N, M in eyes:
        ba: BlockArray = nps.eye(N, M)
        np_arr = np.eye(N, M)
        assert np.allclose(ba.get(), np_arr)
        # Also test identity.
        ba: BlockArray = nps.identity(N)
        np_arr = np.identity(N)
        assert np.allclose(ba.get(), np_arr)