示例#1
0
def test_basic_batch():
    """ Test calling twed_batch using GPUarrays. """

    # Call TWED
    Res = twed_batch(AA, TAA, BB, TBB, nu, lamb, degree)

    print('Python Device Batch cuTWED distances:')
    print(Res)
    # print("Ref\n",Ref)
    assert np.allclose(Ref, Res)
示例#2
0
def test_batch():
    """ Test running the synthetic control dataset"""

    DistanceMatrix = twed_batch(TS, TT, TS, TT, nu, lamb, degree)

    name = 'synthetic_distance_matrix_cutwed_batch'
    with open(f'{name}.npy', 'wb') as fh:
        np.save(fh, DistanceMatrix)

    # with sns.axes_style("white"):
    #     sns.heatmap(DistanceMatrix, square=True,  cmap="YlGnBu")
    #     plt.savefig(f'{name}.png')

    return DistanceMatrix
示例#3
0
def test_basic_batch_float():
    """ Test calling twed_batch using GPUarrays. """

    AAf = AA.astype(np.float32)
    TAAf = TAA.astype(np.float32)
    BBf = BB.astype(np.float32)
    TBBf = TBB.astype(np.float32)

    # Call TWED
    Res = twed_batch(AAf, TAAf, BBf, TBBf, nu, lamb, degree)

    print('Python Device Batch cuTWED distances (single precision):')
    print(Res)
    # print("Ref\n",Ref)
    assert np.allclose(Ref, Res)
示例#4
0
文件: test_Rn.py 项目: tmct/cuTWED
def test_batch():
    D = np.zeros(sz)
    print("Computing twed batch")
    D = twed_batch(AA, TT, BB, TT, nu, lamb, degree)
    assert np.allclose(np.triu(D), DIST)
示例#5
0
# In[5]:

# Set algo params
nu = 1.
lamb = 1.
degree = 2

# In[6]:

# Compute all TWED between series in the synthetic index dataset, and plot

# This takes a while for the full dataset, about enough time to go for a walk,
#    but fits fine; uses only about 150MiB of GPU memory for the full size..
# I doubt this was reasonably computable at all prior to cuTWED....
DistanceMatrix_batch = twed_batch(TS, TT, TS, TT, nu, lamb, degree)

with sns.axes_style("white"):
    sns.heatmap(np.triu(DistanceMatrix_batch), square=True, cmap="YlGnBu")
    plt.plot()

# In[7]:

DistanceMatrix_batch[0, -1]

# In[8]:

# NOTE YOU WILL NEED A HIGH MEM MACHINE TO RUN THE FULL DATASET.....
from psutil import virtual_memory
mem = virtual_memory()
ram = mem.total