LatentOperationLeakyReLU
The ReLU that doesn't murder your negatives
- op
Plain ReLU zeroes out every negative value. LeakyReLU was invented because that's a dumb thing to do in a neural network - it throws away information, and dead neurons happen. This node applies the leaky version to your latent: negatives don't die, they just get scaled down by a small factor. If you're already reaching for LatentOperationReLU as a latent-sculpting tool, this is the version that's actually defensible.
What it does
One line of PyTorch, essentially: F.leaky_relu(latent * alpha, negative_slope=negative_slope).
There are two knobs, and it's worth getting them straight because the naming is a trap:
alpha(FLOAT, default1.0) - this multiplies the input. Every activation node in this pack has one, and it's a gain, not a leak parameter.alpha = 1means the function is applied to the latent as-is; crank it up and you're effectively feeding a brighter/amplified latent into the activation.negative_slope(FLOAT, optional, default0.01, min0) - the actual leak. Values below zero get multiplied by this instead of being killed. Default is PyTorch's textbook0.01.
The gotcha: 0.01 is a very small leak. If your goal is to preserve the negative channel information rather than merely not destroy it, bump negative_slope up - 0.1 to 0.2 is the range most people actually mean when they say "leaky." At 0.01 you've basically built a ReLU with extra steps. And remember latents are roughly zero-mean clouds, so a huge share of values are negative - the leak isn't a corner case here, it's half your data.
The apply step you can't skip
This pack is sneaky. LatentOperationLeakyReLU doesn't return a transformed latent - it returns op, a LATENT_OPERATION closure that describes the transform. The closure multiplies by alpha and applies the leak only when something executes it. There's no apply node in ComfyUI-latent-ops itself, so you need a consumer: Sonar's SonarApplyLatentOperationCFG (which applies an op inside a CFG-guided sampler) or your own little apply node. Wire op straight into a VAE Decode and you'll get a type error, not an image. This is the single most common way people bounce off this pack.
Why you'd bother
Honest answer: it's experimental. Nobody fixes a broken render by sticking LeakyReLU on the latent - but if you're exploring what activation-style transforms do to a latent (contrast behavior, distribution shaping before a CFG or interpolation step), LeakyReLU is the least destructive member of the family. It keeps the negative lobe alive, so downstream operations that expect a roughly symmetric distribution won't suddenly see everything shoved positive. For that specific use it's the one I'd pick over plain ReLU every time.
Install and the rest
Same as every node in the pack: ComfyUI Manager → search ComfyUI-latent-ops, or git clone https://github.com/hnmr293/ComfyUI-latent-ops into ComfyUI/custom_nodes, then restart. No requirements.txt, no model downloads - it's pure PyTorch and ComfyUI already ships that. The author, hnmr293, is the same person behind sd-webui-cutoff and llul, and this pack is his personal latent-manipulation toolkit: 2 stars, no community chatter about it, so don't expect tutorials - expect to read the source. All nodes live under hnmr/latent_ops.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| alpha | FLOAT | 1.0000-10000–10000 | — |
| negative_slopeopt | FLOAT | 0.01000–10000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| op | LATENT_OPERATION | — |