Skip to content

Previous grad is same as current grad due to call by reference. #2

@thebhatman

Description

@thebhatman

The previous grad is same as current grad for all optimization steps except the first step (where prev_grad is zero), due to call by reference happening. Hence the diff is zero for all steps except the first step. Printing diff and plotting it with optimization steps shows this. It can be fixed by state['previous_grad'] = grad.clone(). That way the previous grad will be stored properly, without changing the values at the same memory location.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions