Skip to content

Gradient Is Not Accumulated? #32

@HenryPengZou

Description

@HenryPengZou

Hi Authors,

Congrats on your paper acceptance by NeurIPS!!

I have one question:

If I understand correctly, the code intend to accumulate gradients and update networks every K iterations(K can be set via accum_iter, e.g., accum_iter=2 in you provided script). However, I notice that when you are doing .backward(), 'retain_graph=True' is not set. Does this mean that the gradient is not accumulated and we are updating network using the gradient from the Kth iteration instead of the gradient accumulation from 1 to K ith ?

self._scaler.scale(loss).backward(create_graph=create_graph)

Thanks in advance for your time~

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