Nodes/ComfyDL/Synthetic Data
ComfyUI Node

Synthetic Data

A fake dataset generator that makes your first training loop honest

By Cynthia-lxx·Created 2 months ago·Updated 2 days ago· 6
Synthetic Data
    • X
    • y
    num_features2
    num_examples100
    noise_std0.010
    seed0

    The single most underrated trick in learning deep learning is training on data you can verify by hand. Synthetic Data exists for exactly that: it generates a fake linear regression dataset - features X, labels y = Xw + b + noise - where you control the ground truth, because the true weights are drawn from a standard normal inside the node. You know the answer the model is supposed to converge to. That's a luxury real datasets never give you.

    This is the textbook d2l synthetic_data function lifted into a ComfyUI node, and it's the starting pistol for the pack's canonical linear regression demo. Generate data, push X through the Linear Regression node, compare with Squared Loss, apply an SGD step, and watch a model learn from scratch with data you could have generated in your head.

    The inputs that matter

    Four widgets, all of them self-explanatory:

    • num_features - how many columns X has. The true weights are drawn N(0,1), one per feature.
    • num_examples - how many rows. Default 100; the demo works fine with a few hundred.
    • noise_std - the standard deviation of the Gaussian noise added to the labels. Set it to 0 and you get a perfectly linear dataset; crank it up and the fit gets visibly sloppy. This is the dial that teaches you what "noise" does to a regression.
    • seed - reproducible randomness. Same seed, same data, every run. Default 0, and unlike a lot of ComfyUI randomness there's no control_after_generate trap here - the number you set is the number that gets used.

    Outputs

    Two tensors, both cdlTensor:

    • X - shape (num_examples, num_features).
    • y - shape (num_examples, 1), the labels with noise added.

    They're already aligned, so you can wire X straight into Linear Regression and y into Squared Loss and start looping. If you want to see what you made, run X through Tensor → String - yes, a 100-row tensor prints truncated, but that's exactly what a debug view is for.

    Installing it

    It's part of ComfyDL. ComfyUI Manager, search "ComfyDL", install, restart. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Cynthia-lxx/ComfyDL
    pip install -r ./ComfyDL/requirements.txt
    

    The pack's only extra dependency is matplotlib - no model files, no checkpoint downloads, no torch version drama.

    Gotchas

    Two things to keep straight. First, the true weights and bias are generated inside the node and never shown to you directly - you don't get to choose w, only the shape of the data and the noise. That's deliberate (it mimics the d2l setup), but if you were hoping to hand-feed a specific ground-truth weight, this isn't the node. Second, both outputs are custom cdlTensor sockets, so they only feed other ComfyDL nodes. And don't sleep on the seed: in an educational pack the reproducibility isn't a nicety, it's the whole point - you want the same data when you change the learning rate, or you can't tell what actually changed the loss curve. The pack is young with almost no community chatter yet, but this node is a handful of torch.normal calls, so there's little that can break in practice.

    Categoryd2l/TorchOps

    Inputs (4)

    NameTypeDefaultDescription
    num_featuresINT21–1000
    num_examplesINT1001–1000000
    noise_stdFLOAT0.0100–10
    seedINT00–99999

    Outputs (2)

    NameTypeDescription
    XTENSOR
    yTENSOR