Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do set y neq x #143

Open
bentoayr opened this issue Apr 25, 2024 · 1 comment
Open

How do set y neq x #143

bentoayr opened this issue Apr 25, 2024 · 1 comment

Comments

@bentoayr
Copy link

Hello,
I am trying to build a denoising auto encoder.
Is there a way to make the target data be different from the input data?
In particular, I want the input data to be noisy and the target data to be clean data.
In math, instead of having min_f L(x,f(x)) for some loss function I want to have min_f L(x,f(x + noise))?
Cheers !

@clementchadebec
Copy link
Owner

Hello, sorry for the late reply. To do this you will need to amend a bit the implementation of the models themselves. The easiest way to do so is to fork this repo and installing it in editable model running

pip install -e .

Then you can amend the forward function so that the noisy data and clean data can be obtained from your datasets.

def forward(self, inputs: BaseDataset, **kwargs):
"""
The VAE model
Args:
inputs (BaseDataset): The training dataset with labels
Returns:
ModelOutput: An instance of ModelOutput containing all the relevant parameters
"""
x = inputs["data"]
encoder_output = self.encoder(x)
mu, log_var = encoder_output.embedding, encoder_output.log_covariance
std = torch.exp(0.5 * log_var)
z, eps = self._sample_gauss(mu, std)
recon_x = self.decoder(z)["reconstruction"]
loss, recon_loss, kld = self.loss_function(recon_x, x, mu, log_var, z)

I hope this helps,

Best,

Clément

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants