Contractive_Autoencoder_in_Pytorch icon indicating copy to clipboard operation
Contractive_Autoencoder_in_Pytorch copied to clipboard

bug; the CAE penalty is incorrect for any non-sigmoid activation

Open Sycor4x opened this issue 6 years ago • 4 comments

The CAE class uses the relu nonlinearity. https://github.com/avijit9/Contractive_Autoencoder_in_Pytorch/blob/master/CAE_pytorch.py#L61

However, the way the CAE loss is computed is only valid for sigmoid activations. This is easy enough to show: the derivative of the relu activation is 1 for positive inputs and 0 for negative inputs.

The link provided in the docstring for the CAE loss assumes the sigmoid nonlinearity; it's not attempting to derive the contractive penalty in general.

Sycor4x avatar Dec 29 '18 01:12 Sycor4x

I agree with @Sycor4x . The contractive_loss formula used in this code is only valid for logistic sigmoid activation function. However in this code the activation function of the hidden units is ReLU.

haQiu-oMNi avatar Feb 26 '19 20:02 haQiu-oMNi

I agree with @Sycor4x and @haQiu-oMNi too. Approximation in this code doesn't hold for non-linear encoder which has ReLU as an activation function.

DaikiTanak avatar Nov 10 '19 14:11 DaikiTanak

I agree with @Sycor4x, @haQiu-oMNi and @DaikiTanak . Could anyone provide the collection of CAE loss of all types of activations?

Sharp-rookie avatar Jun 17 '23 09:06 Sharp-rookie

@Sharp-rookie The way to write the code to compute the CAE loss for arbitrary activations is to use PyTorch to compute the Jacobian for you, and then compute the norm from there. It's not hard to code up. Unfortunately, I don't have access to the code that I wrote to do it anymore.

Sycor4x avatar Jun 18 '23 00:06 Sycor4x