lejon / T-SNE-Java

Pure Java implementation of Van Der Maaten and Hinton's t-sne clustering algorithm
197 stars 60 forks source link

NegativeArraySizeException Thrown Using BarnesHut Version #20

Open msteph11 opened 4 years ago

msteph11 commented 4 years ago

Hi,

I used the code provided in the ReadMe to run the BarnesHut Version on a matrix with 200 rows and 49278 columns, and got this error:

Exception in thread "main" java.lang.NegativeArraySizeException
    at org.ejml.data.DenseMatrix64F.<init>(DenseMatrix64F.java:156)
    at org.ejml.alg.dense.decomposition.bidiagonal.BidiagonalDecompositionRow_D64.handleU(BidiagonalDecompositionRow_D64.java:220)
    at org.ejml.alg.dense.decomposition.bidiagonal.BidiagonalDecompositionRow_D64.getU(BidiagonalDecompositionRow_D64.java:183)
    at org.ejml.alg.dense.decomposition.bidiagonal.BidiagonalDecompositionRow_D64.getU(BidiagonalDecompositionRow_D64.java:34)
    at org.ejml.alg.dense.decomposition.svd.SvdImplicitQrDecompose_D64.computeUWV(SvdImplicitQrDecompose_D64.java:243)
    at org.ejml.alg.dense.decomposition.svd.SvdImplicitQrDecompose_D64.decompose(SvdImplicitQrDecompose_D64.java:193)
    at org.ejml.alg.dense.decomposition.svd.SvdImplicitQrDecompose_D64.decompose(SvdImplicitQrDecompose_D64.java:46)
    at com.jujutsu.tsne.PrincipalComponentAnalysis.computeBasis(PrincipalComponentAnalysis.java:143)
    at com.jujutsu.tsne.PrincipalComponentAnalysis.pca(PrincipalComponentAnalysis.java:267)
    at com.jujutsu.tsne.barneshut.BHTSne.run(BHTSne.java:89)
    at com.jujutsu.tsne.barneshut.BHTSne.tsne(BHTSne.java:53)
    at gsc.Main.main(Main.java:27)

The matrix has numbers that range from 0 to 127511. I was wondering why this exception was being thrown and what a possible workaround/solution would be.

Thanks

kmnip commented 4 years ago

I found that I only have this issue if the input matrix is wide. No NegativeArraySizeException is thrown if the input matrix were transposed from wide to long (using MatrixOps.transposeSerial(X)).