Skip to content

{IndexError}index 2048 is out of bounds for dimension 1 with size 2048 #3

Open
@zfhxi

Description

@zfhxi

Hello, my test code is as follow:

X1 = torch.randn([10, 2048]).cuda()
X_emb = TorchTSNE(n_components=2, perplexity=100., n_iter=1000).fit_transform(X1)

Sometimes, it will occur '{IndexError}index 2048 is out of bounds for dimension 1 with size 2048', I find the reason is that as 121 line in the tsne_pytorch.py, there may be out of bounds:

119 for i in range(d):
120     if l[i, 1] != 0:
121         M[:, i+1] = M[:, i]
122         i += 1

Concretely, i may equal to d-1 in 121 line which causes M[:,i+1] will be out of bounds(we know M is dxd).

I wonder if the modified code as follow is right?

for i in range(d-1):
    if l[i, 1] != 0:
        M[:, i+1] = M[:, i]
        i += 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions