Random Tensor
ComfyDL's noise generator for testing, init, and inputs
- tensor
Sometimes you just need some random numbers. CdlRandomTensor generates a tensor of any shape you ask for, drawn from one of three distributions, with an optional seed. It sounds trivial - and it kind of is - but in a pack built for doing deep learning in a node graph, random tensors are how you feed a GAN's noise vector, initialize a synthetic-data experiment, or just get something into a graph you're still building.
This is ComfyDL in its purest form: a thin, honest wrapper around a torch call (torch.randn, torch.rand, torch.randint), wrapped so you can drive it from the graph instead of a Python prompt. Nothing fancy, but it's the node every experimental workflow ends up needing.
The inputs
shape- a comma-separated string, e.g."4,4"or"2,3,4". The only required thing that isn't a distribution parameter.dist-normal,uniform, orrandint.mean/std- the normal distribution's parameters (defaults 0.0 / 1.0, i.e. standard normal).low/high- bounds foruniformandrandint. Note both are from[low, high)-highis exclusive. Forrandint, values are integers.seed- the quiet superpower. Default-1= random every run; set it to0or above and the RNG is fixed, giving you the same tensor every time you execute. That's how you make a test reproducible.
Output: tensor, a cdlTensor of your requested shape.
The seed matters more than you think
ComfyUI caches aggressively, and a random node that produces different values each run can subtly poison caching around it. When you're debugging whether a change upstream actually changed the result, lock the seed to -1... no, the other way: lock it to a fixed value. A fixed seed turns "did my edit change the output?" from a gamble into a test. Reserve -1 for when you genuinely want fresh randomness per run - a GAN's noise input, a Monte Carlo experiment - and even then, pin it to reproduce a specific result you liked.
Installing ComfyDL
Standard for this pack - light:
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
cd ComfyDL && pip install -r requirements.txt
Restart ComfyUI; it's under ComfyDL → Tensor Basic. ComfyUI Manager users search "ComfyDL". Only dependency is matplotlib; no downloads.
Gotchas
Empty shape string raises a ValueError - ComfyUI will show it as a node error, so keep the default "4,4" if you're unsure. And the output is a cdlTensor, which means it only connects to other ComfyDL nodes. Don't try to feed it into a stock ComfyUI noise node or sampler - the type won't match, and that's by design; this pack is a self-contained sandbox for building neural nets, not for diffusion sampling.
One more thing worth knowing: torch.manual_seed is global, not per-node. If you've got two Random Tensor nodes with the same seed in one graph, they'll be correlated (identical sequences) rather than independent. Give them different seeds if you want them to behave like separate draws.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| shape | STRING | 4,4 | — |
| dist | COMBO | normal | 3 options: normal, uniform, randint |
| mean | FLOAT | 0.0-1000000–1000000 | — |
| std | FLOAT | 1.00–1000000 | — |
| low | FLOAT | 0.0-1000000–1000000 | — |
| high | FLOAT | 1.0-1000000–1000000 | — |
| seed | INT | -1-1–2147483647 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| tensor | TENSOR | — |