Skip to content

Commit 5433962

Browse files
authored
[docs] Batched seeds (#6237)
batched seed
1 parent df476d9 commit 5433962

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/source/en/using-diffusers/reusing_seeds.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ Now, define four different `Generator`s and assign each `Generator` a seed (`0`
4141
generator = [torch.Generator(device="cuda").manual_seed(i) for i in range(4)]
4242
```
4343

44+
<Tip warning={true}>
45+
46+
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.
47+
48+
For example, if you want to use the same seed to create 4 identical images:
49+
50+
```py
51+
❌ [torch.Generator().manual_seed(seed)] * 4
52+
53+
✅ [torch.Generator().manual_seed(seed) for _ in range(4)]
54+
```
55+
56+
</Tip>
57+
4458
Generate the images and have a look:
4559

4660
```python

0 commit comments

Comments
 (0)