Skip to content

Commit

Permalink
[docs] Batched seeds (#6237)
Browse files Browse the repository at this point in the history
batched seed
  • Loading branch information
stevhliu authored Dec 20, 2023
1 parent df476d9 commit 5433962
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/source/en/using-diffusers/reusing_seeds.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ Now, define four different `Generator`s and assign each `Generator` a seed (`0`
generator = [torch.Generator(device="cuda").manual_seed(i) for i in range(4)]
```

<Tip warning={true}>

To create a batched seed, you should use a list comprehension that iterates over the length specified in `range()`. This creates a unique `Generator` object for each image in the batch. If you only multiply the `Generator` by the batch size, this only creates one `Generator` object that is used sequentially for each image in the batch.

For example, if you want to use the same seed to create 4 identical images:

```py
❌ [torch.Generator().manual_seed(seed)] * 4

✅ [torch.Generator().manual_seed(seed) for _ in range(4)]
```

</Tip>

Generate the images and have a look:

```python
Expand Down

0 comments on commit 5433962

Please sign in to comment.