Skip to content

Commit 1096f88

Browse files
authored
sampling bug fix in diffusers tutorial "basic_training.md" (huggingface#8223)
sampling bug fix in basic_training.md In the diffusers basic training tutorial, setting the manual seed argument (generator=torch.manual_seed(config.seed)) in the pipeline call inside evaluate() function rewinds the dataloader shuffling, leading to overfitting due to the model seeing same sequence of training examples after every evaluation call. Using generator=torch.Generator(device='cpu').manual_seed(config.seed) avoids this.
1 parent cef4a51 commit 1096f88

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/source/en/tutorials/basic_training.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Then, you'll need a way to evaluate the model. For evaluation, you can use the [
260260
... # The default pipeline output type is `List[PIL.Image]`
261261
... images = pipeline(
262262
... batch_size=config.eval_batch_size,
263-
... generator=torch.manual_seed(config.seed),
263+
... generator=torch.Generator(device='cpu').manual_seed(config.seed), # Use a separate torch generator to avoid rewinding the random state of the main training loop
264264
... ).images
265265

266266
... # Make a grid out of the images

0 commit comments

Comments
 (0)