Nodes/ComfyUI-latent-ops/LatentOperationCELU
ComfyUI Node

LatentOperationCELU

The ELU variant that stays smooth below zero

By hnmr293·Created about a year ago·Updated about a year ago· 2
LatentOperationCELU
    • op
    alpha1.0000

    If you're browsing the LatentOperation* family in hnmr293's ComfyUI-latent-ops pack, CELU is one of the ones you'll skim past and probably be right to. It's the continuously differentiable ELU: like ELU, it keeps negative values alive instead of zeroing them, but it smooths out the kink at zero. For latent manipulation that's a niche distinction - but if you're shaping distributions with curves rather than straight lines, it's the difference between a soft transition and a hard corner.

    CELU is part of the pack's activation zoo, where every node follows the same pattern: capture a parameter, hand back a deferred operation.

    How it works

    The node builds a closure that applies torch.nn.functional.celu(latent * alpha) when something finally runs it. Note what that alpha is doing - it's a pre-scale of the latent before the activation, not CELU's internal slope parameter. At the default alpha = 1.0 you get plain CELU: positive values pass through, negatives curve smoothly toward -1 asymptotically, with no discontinuity at zero. Crank alpha above 1 and the whole curve compresses/stretches along the input axis.

    The deferred-op pattern

    Like every node here with "Operation" in the name, the op output is a LATENT_OPERATION - a callable that expects a latent and returns a transformed one - not a latent. The pack ships no node that applies an op, so you need a consumer that accepts LATENT_OPERATION or a small custom apply node (op(latent["samples"])). Wire op straight into VAE Decode and it won't connect; that's the design, not a bug.

    What matters

    • alpha - FLOAT, default 1.0, range -10000 to 10000, step 0.0001. Leave at 1.0 for plain CELU; adjust if you want the curve steeper or shallower.
    • op - the only output. Deferred operation.

    Installing it

    Same pack, same nothing-to-install story: pure torch, no requirements.txt, no model downloads. ComfyUI Manager → search "ComfyUI-latent-ops" → install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/hnmr293/ComfyUI-latent-ops
    

    Restart ComfyUI; it's under hnmr/latent_ops.

    Troubleshooting

    Two things trip people up. First, an op output that won't plug into a latent input - missing Apply step, and it applies to every Operation node in this pack. Second, expecting alpha to change CELU's negative saturation: it doesn't, it scales the input. If you want the classic ELU soft-floor instead of the fully-smooth version, that's LatentOperationELU. And if this node feels like overkill for your workflow, it probably is - reach for it when you specifically need a smooth saturating curve below zero, which for most people is approximately never.

    Categoryhnmr/latent_ops

    Inputs (1)

    NameTypeDefaultDescription
    alphaFLOAT1.0000-10000–10000

    Outputs (1)

    NameTypeDescription
    opLATENT_OPERATION