swh:1:snp:39d5aa88ec19187d5f6c7d91d5a7e02d6ac7c2c2
Raw File
Tip revision: 241bf7ad2b806f6677a5e23534247f35f3a70f10 authored by rballester on 19 February 2023, 19:35:27 UTC
Exact method for moments
Tip revision: 241bf7a
test_init.py
import numpy as np
import tntorch as tn
import torch
torch.set_default_dtype(torch.float64)


def test_from_ndarray():

    for i in range(100):
        gt = np.random.rand(*np.random.randint(1, 8, np.random.randint(1, 6)))
        t = tn.Tensor(gt)
        reco = t.numpy()
        assert np.linalg.norm(gt - reco) / np.linalg.norm(gt) <+ 1e-7
back to top