TimeLovercc / CAF-GNN

[CIKM 2023] Towards Fair Graph Neural Networks via Graph Counterfactual.
https://arxiv.org/abs/2307.04937
MIT License
11 stars 3 forks source link

An Error Occurs when reproducing CAF & A question about Data Normalization #3

Open AllenZ01 opened 8 months ago

AllenZ01 commented 8 months ago

Hi.

1, An Error Occurs when reproducing CAF

An error occurs when I reproduce CAF, in line trainer.fit(model, datamodule=data_module):

RuntimeError: It looks like your LightningModule has parameters that were not used in producing the loss returned by training_step. If this is intentional, you must enable the detection of unused parameters in DDP, either by setting the string value strategy='ddp_find_unused_parameters_true' or by setting the flag in the strategy with strategy=DDPStrategy(find_unused_parameters=True).

2. A question about Data Normalization

And I think this line self.data.x[:, sens_idx] = self.data.sens does not re-asign the sensitive value $s$ to $s\in \lbrace0,1 \rbrace$. Since this is done before the normalization. To be specific, in the implementation of torch_geometric.data.Dataset,

The data object will be transformed before every access

which means that:

  1. when executing dataset = Bail(...,transform=NormalizeFeatures()), features dataset[0].x are not normalized.

  2. when executing data = dataset[0] (i.e. accessing data object), features data.x are implicitly normalized.

Yet this line self.data.x[:, sens_idx] = self.data.sens is executed in dataset = Bail(...,transform=NormalizeFeatures()), in other words, the re-asigning of sensitive values are executed beform feature normalization. And you use Row-Normalization (torch_geometric.transforms.NormalizeFeatures) in your code, resulting in a variety values of $s$: $s \in (0,1)$. e.g. might be $0.18$, $0.23$ depending on other features' values of this individual.

TimeLovercc commented 8 months ago

Sorry for the late reply. I am busy these days. Now I have time to check this issue.

TimeLovercc commented 8 months ago

I will solve it this weekend. Sorry for the waiting.

AllenZ01 commented 8 months ago

Hi. I'm not in a hurry. Take your time! :)

TimeLovercc commented 7 months ago

Sorry for the waiting. Can you come up with a PR and I can review the changes?

AllenZ01 commented 7 months ago

Hi, I haven't changed anything, since I'm not so familiar with Pytorch-Lightning.

dalianshiyi commented 5 months ago

Hello, I also encountered the same problem, has it been solved now?

TimeLovercc commented 5 months ago

@dalianshiyi Not yet. Can you post the reproduce guidelines to help me locate the problem?