NNT Random Tensor Generator
Need fake data? NNT Random Tensor Generator rolls a batch of synthetic tensors
- tensor
- info_message
- batch_size
Before you spend an afternoon hunting down a real dataset, this node will fabricate one for you. NNT Random Tensor Generator is the "make up the data first" node of the Neural Network Toolkit: you tell it a shape and a distribution, and it hands you a brand-new PyTorch tensor ready to feed into a training or gradient experiment. It's the fastest way to find out whether the network you just wired together even runs before you commit to real data.
That's the niche this whole pack lives in. The Neural Network Toolkit (NNT) from inventorado is a visual deep-learning playground - you build raw PyTorch models out of layer nodes, train them, and watch the numbers, none of which touches the KSampler side of ComfyUI. Here the TENSOR outputs are raw torch tensors, and this node is where a lot of them get born.
How it works
Under the hood it's a thin wrapper around torch's random generators. Pick a distribution and the node calls the matching torch.empty(shape).uniform_(...), .normal_(...), .bernoulli_(...), and so on. Seven distributions are on the menu: uniform, normal, bernoulli, geometric, exponential, lognormal, and cauchy. There's a seed input (default -1 means "don't seed") so you can make an experiment reproducible or randomize every run.
The inputs that actually matter:
- distribution - what shape the randomness takes. Uniform and normal cover most "I just need numbers" use.
- data_shape - a Python list as a string, like
[100, 10]for 100 samples with 10 features. This is the whole point of the node. - seed - set it to make the same tensor come out every run.
- min_value / max_value - used by uniform (and to derive bernoulli's probability).
- mean / std - used by normal, lognormal, and cauchy.
- rate - used by geometric and exponential.
- data_type and requires_grad - float32/float64/int32/int64, and whether the tensor should track gradients (defaults to True, which matters if you want to use it in the autodiff exercises).
You get three outputs: tensor (the goods), info_message (a string describing what was generated), and batch_size - which is just the first dimension of your shape, handy for wiring into batch-oriented nodes.
How to install it
The node ships with the whole NNT pack, so install once:
cd ComfyUI/custom_nodes
git clone https://github.com/inventorado/ComfyUI_NNT.git
cd ComfyUI_NNT
pip install -r requirements.txt
Then restart ComfyUI. On a Windows standalone install, point pip at the embedded Python:
..\..\..\python_embeded\python.exe -m pip install -r requirements.txt
ComfyUI Manager can also handle it - search for "ComfyUI Neural Network Toolkit NNT". Fair warning: the requirements list is long (torch, numpy, pandas, matplotlib, sklearn, transformers, onnx, statsmodels, shap pinned at 0.41.0, and more), so the first install takes a while. Worth it if you're serious about this pack.
Where people get burned
Two things. First, data_shape is parsed with eval(), so keep it to a plain list literal like [100, 10] - nothing clever. Second, the integer dtypes get cast back to float automatically "for training," so don't expect to generate a clean int64 tensor and have it stay that way when you wire it into a training node. And a bernoulli tensor's probability is derived as the midpoint of min/max, which reads weird if you're used to passing p directly - set min=0 and max=1 and you get p=0.5, which is the honest reading of it.
The one you'd reach for first: this node. If you're teaching yourself a concept or testing an architecture, fake data is faster and more forgiving than real data - and this is the most direct way to get it.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| distribution | COMBO | uniform | 7 options: uniform, normal, bernoulli, geometric, exponential, lognormal, +1 |
| data_shape | STRING | [100, 10] | — |
| data_type | COMBO | float32 | 4 options: float32, float64, int32, int64 |
| min_value | FLOAT | 0.0-1000–1000 | — |
| max_value | FLOAT | 1.0-1000–1000 | — |
| mean | FLOAT | 0.0-1000–1000 | — |
| std | FLOAT | 1.00–100 | — |
| rate | FLOAT | 1.00–100 | — |
| requires_grad | COMBO | True | 2 options: True, False |
| seed | INT | -1-1–99999999 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| tensor | TENSOR | — |
| info_message | STRING | — |
| batch_size | INT | — |