RandomTensor
Synthetic data on tap for testing a graph that has no data yet
- TORCH_TENSOR
RandomTensor does one boring, indispensable thing: it generates a random TORCH_TENSOR of a shape you specify. In a pack where every node feeds on tensors - ReshapeTensor, SliceTensor, TensorsToDataset, TrainModel - this is the node you use to test the plumbing before real data exists. Build your training graph, feed it a (64, 784) random tensor, and find out your batch shape is wrong without downloading a single MNIST image.
It's part of EternalKernel PyTorch Nodes (TashaSkyUp), the raw-PyTorch-inside-ComfyUI pack. RandomTensor is squarely in the "debug and prototype" corner of it, which is a legitimate and heavily-used corner.
How it works
You give it a shape string and pick an init_method:
rand- uniform values in [0, 1). The default.randn- standard-normal (bell curve) values.randint- random integers from 0 to 99 (the hardcoded range).- the
_likevariants (rand_like,randn_like,randint_like) - same draws, but they build a throwaway tensor of your shape first, which is a quirk you can safely ignore.
The dtype dropdown lists every dtype torch knows about (the 55-item enum is auto-generated from the installed torch), defaulting to torch.float32. Just leave it there unless you specifically need ints or a half-precision tensor.
One format gotcha that will bite you on day one: the shape string is parsed by stripping the parentheses and splitting on commas, so it must look like (2,3) - parens included, spaces tolerated. The default (1,1) is your hint. It's a small thing, but this pack's shape-string conventions are inconsistent across nodes (ReshapeTensor wants 1, -1, no parens), so don't assume they match.
Inputs and outputs
- shape (required STRING) -
(rows, cols)style, e.g.(16, 10)or(64, 784). - dtype (optional enum, 55 torch dtypes) - leave on
torch.float32unless you know otherwise. - init_method (optional enum) -
rand/randn/randint/ the_likevariants. - Output: TORCH_TENSOR - wire it anywhere a tensor is expected.
(2,3)gives you six values;(64,784)gives you a fake batch.
Installing it
Shared with the whole pack:
cd ComfyUI/custom_nodes
git clone https://github.com/TashaSkyUp/EternalKernelPytorchNodes.git
cd EternalKernelPytorchNodes
pip install -r requirements.txt
Restart ComfyUI and it's under ETK/pytorch (or install via Manager, search "EternalKernel PyTorch Nodes").
Troubleshooting
The two failure modes are both easy to read: an Unsupported dtype ValueError means the dropdown served you something the node's internal lookup couldn't match (unlikely but possible across torch versions), and an unparseable shape throws a plain Python int() error - check for missing parentheses. Also remember random values change on every run, which is exactly what you want for testing but a trap if you were hoping for reproducible data. There's no seed input here, so if you need stability, save the tensor with SaveTorchTensor once and load it back.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| shape | STRING | (1,1) | — |
| dtypeopt | COMBO | 55 options: torch.uint8, torch.int8, torch.int16, torch.int16, torch.int32, torch.int32, +49 | |
| init_methodopt | COMBO | rand | 6 options: rand, randn, randint, randint_like, rand_like, randn_like |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TORCH_TENSOR | TORCH_TENSOR | — |