AnoGAN: `index_D_layer_for_recon_error` is documented but never used
Docstring (pyod/models/anogan.py:144-147):
index_D_layer_for_recon_error : int, optional (default = 1)
This is the index of the hidden layer in the discriminator for which
the reconstruction error will be determined between query sample and
the sample created from the latent space.It is stored at anogan.py:210 and never read. The discriminator term of the query loss (anogan.py:370-381) compares self.discriminator(query_sample) with self.discriminator(sample_gen), i.e. the final sigmoid output, not a hidden layer, and the Discriminator module (anogan.py:64-88) has no way to return an intermediate activation.
Why it matters: in the AnoGAN paper the discrimination loss uses an intermediate feature layer of D (feature matching), which is what the parameter promises; the implementation uses the 1-dimensional output, so the "latent discriminator" loss is a comparison of two probabilities. Users passing a different index see no change. Same shape as #714.
Proposed fix: have Discriminator.forward optionally return the activation at index_D_layer_for_recon_error and use it in the query loss; test that changing the index changes decision_scores_. Or drop the parameter if the output-level loss is intended. Happy to PR either way.
Verified on v3.6.6; drafted with Claude Code assistance and checked by hand.
Source: yzhao062/pyod