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

The correspondence between each row of the latent_codes_state_dict['weight'] matrix and id and expression #26

Open
self-hacker opened this issue Nov 4, 2024 · 0 comments

Comments

@self-hacker
Copy link

self-hacker commented Nov 4, 2024

How to check which id and expression each row of the latent_codes_state_dict['weight'] matrix in a checkpoint of a certain epoch corresponds to?
I tried adding some code to the get_loader function in face_dataset.py to try to match them to each row by looking at the id and expr loading order in the batch, but I found that the loading order is different for each run, and there are repeated idx being loaded. Is the random seed somewhere not fixed?
What should I do to see the correspondence between the latent_codes_state_dict['weight'] matrix and id and expression
def get_loader(self, shuffle=True):
random.seed(0)
torch.manual_seed(0)
torch.cuda.manual_seed(0)
np.random.seed(0)

    print("Sampler order:")
    dataloader=torch.utils.data.DataLoader(
        self, batch_size=self.batch_size, num_workers=1, shuffle=shuffle,
        worker_init_fn=self.worker_init_fn,
        pin_memory=True)
    
    import pandas as pd
    id_expression_map = []
    for batch in dataloader:
        batch_ids = batch['iden']
        batch_expressions = batch['expr']
        # 记录每个样本的顺序
        id_expression_map.extend(zip(batch_ids, batch_expressions))

    # 将数据转换为 DataFrame,以保证行顺序一致
    id_expr_df = pd.DataFrame(id_expression_map, columns=['id', 'expression'])
    print(id_expr_df)

    return torch.utils.data.DataLoader(
        self, batch_size=self.batch_size, num_workers=1, shuffle=shuffle,
        worker_init_fn=self.worker_init_fn,
        pin_memory=True)
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

1 participant