-
Notifications
You must be signed in to change notification settings - Fork 584
Open
Description
With ref to :
stylegan2-pytorch/stylegan2_pytorch/stylegan2_pytorch.py
Lines 215 to 226 in 0588213
| def gradient_accumulate_contexts(gradient_accumulate_every, is_ddp, ddps): | |
| if is_ddp: | |
| num_no_syncs = gradient_accumulate_every - 1 | |
| head = [combine_contexts(map(lambda ddp: ddp.no_sync, ddps))] * num_no_syncs | |
| tail = [null_context] | |
| contexts = head + tail | |
| else: | |
| contexts = [null_context] * gradient_accumulate_every | |
| for context in contexts: | |
| with context(): | |
| yield |
I think "map(lambda ddp: ddp.no_sync, ddps)" should be changed to "list(map(lambda ddp: ddp.no_sync, ddps))"
Otherwise, since map is an iterator, it can be used only once, and then the function of gradient_accumulate cannot work well.
Metadata
Metadata
Assignees
Labels
No labels