vnmabus / dcor

Distance correlation and related E-statistics in Python
https://dcor.readthedocs.io
MIT License
144 stars 26 forks source link

Question about the shape of the input array #50

Closed Sunflowerbeaut closed 1 year ago

Sunflowerbeaut commented 1 year ago

I have created an autoencoder as a feature extractor. To make the output of the encoder as independent as possible from the input. I chose dcor as an additional loss to train the autoencoder. However, I have some problems when calculating the dcor loss. The input shape of the batch data is [32, 1, 28, 14] and the embedding shape is [32, 8, 14, 7]. But it seems that the calculation cannot be performed directly. The Error part is as follows: image

I wonder if there have some way to calculate the dcor loss of the input and the embedding. Hope to get your answer :)

vnmabus commented 1 year ago

What distance_correlation expects is two matrices N x P, and N x Q with N the number of observations and P and Q the dimensions of the two random vectors.

Depending on what your dimensions mean, you want to reshape the tensor to put them as part of one of these two categories, or to compute distance_correlation several times (you could use rowwise in this case).

vnmabus commented 1 year ago

Were you able to fix your problem?

Sunflowerbeaut commented 1 year ago

Thank you for your response. I have conducted experiments on MNIST dataset, but the distance correlation hardly changed. Anyway, thank you again! Hope you have a wonderful day.