Hi,
since I'm right now in the process of looking through multiple different TRL models and am carefully considering their implementations, I just want to point out that the implementation that is in this project for corrupting features is incorrect - in the sense that it is not the same as presented in the original paper.
In the original paper the authors write that they replace the corrupted features "by a random draw from that feature’s empirical marginal distribution, which is defined as the uniform distribution over the values that feature takes on across the training dataset." Creating a simple uniform distribution from the min and max values of each feature is not the same thing.
I am referring to this specific line where you define your distribution:
self.marginals = Uniform(torch.Tensor(features_low), torch.Tensor(features_high))
You later sample from it and replace using a mask:
x_random = self.marginals.sample(torch.Size((batch_size,))).to(x.device)
x_corrupted = torch.where(corruption_mask, x_random, x)
What you need actually need to do is to sample from the original dataset - something like (take this as inspiration, not the actual code that should be used):
np.random.choice(original_data, replacement=True)
Hi,
since I'm right now in the process of looking through multiple different TRL models and am carefully considering their implementations, I just want to point out that the implementation that is in this project for corrupting features is incorrect - in the sense that it is not the same as presented in the original paper.
In the original paper the authors write that they replace the corrupted features "by a random draw from that feature’s empirical marginal distribution, which is defined as the uniform distribution over the values that feature takes on across the training dataset." Creating a simple uniform distribution from the min and max values of each feature is not the same thing.
I am referring to this specific line where you define your distribution:
You later sample from it and replace using a mask:
What you need actually need to do is to sample from the original dataset - something like (take this as inspiration, not the actual code that should be used):