emadeldeen24 / CA-TCC

[TPAMI 2023] Self-supervised Contrastive Representation Learning for Semi-supervised Time-Series Classification
https://ieeexplore.ieee.org/document/10233092
124 stars 32 forks source link

Problem with self_supervised mode training #4

Closed Not-xuexi closed 8 months ago

Not-xuexi commented 8 months ago

When i run the main.py with self_supervised mode training

the following error occurs.

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part.

def permutation(x, max_segments=5, seg_mode="random"): orig_steps = np.arange(x.shape[2])

num_segs = np.random.randint(1, max_segments, size=(x.shape[0]))

ret = np.zeros_like(x)
for i, pat in enumerate(x):
    if num_segs[i] > 1:
        if seg_mode == "random":
            split_points = np.random.choice(x.shape[2] - 2, num_segs[i] - 1, replace=False)
            split_points.sort()
            splits = np.split(orig_steps, split_points)
        else:
            splits = np.array_split(orig_steps, num_segs[i])
        warp = np.concatenate(np.random.permutation(splits)).ravel()     (Error comes from this line)
        ret[i] = pat[0,warp]
    else:
        ret[i] = pat
return torch.from_numpy(ret)

how to solve it? Thanks

emadeldeen24 commented 8 months ago

I think it might be related to the numpy version. Try downgrading to numpy 1.21.0.