Skip to content

RNG for torch.randn_like #27072

@gao462

Description

@gao462

I hope that torch.randn_like can take generator=RNG argument as other random generation functions.

init_params = [torch.randn_like(param.data, generator=rng) for param in nn.parameters()]

I know that the equivalence

init_params = [torch.randn(param.size(), generator=rng).to(param.data) for param in nn.parameters()]

can work.
But for consistency, I still hope that all random related functions can take generator as an argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNot as big of a feature, but technically not a bug. Should be easy to fixmodule: randomRelated to random number generation in PyTorch (rng generator)triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions