ComfyUI Node

Ptf Sigmoid

Squish scores into a 0-to-1 probability

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptf Sigmoid
    • PTCALLABLE

    Sigmoid takes any real number and squashes it into (0, 1) - the classic way to turn a raw score into a single probability. Ptf Sigmoid hands you that function as a callable component: no inputs, one PTCALLABLE output, ready to be dropped into a Pt Apply Function node or a model closure. Reach for it when you have a binary decision to express as a probability, or a final layer that needs to end up bounded between 0 and 1.

    How it works

    The node returns torch.nn.functional.sigmoid. Output type PTCALLABLE; you apply it to a tensor via Pt Apply Function (which takes a tensor plus a callable and returns the transformed tensor) or inside any model node that accepts a closure. As a function it composes with everything: sigmoid after a linear layer, sigmoid as a whole model's output, sigmoid before a binary loss.

    The math worth internalizing: sigmoid(0) = 0.5, large positives approach 1, large negatives approach 0. That's why it's the go-to for binary classification output. Its reputation problem - vanishing gradients when the inputs get far from zero, which makes deep stacks hard to train - is why the pack also ships Ptf ReLU and Ptf SiLU for hidden layers. Use sigmoid where it belongs: the output of a binary-probability task, not a deep hidden layer.

    The one output

    • PTCALLABLE - the sigmoid function. No inputs.

    The practical choice: sigmoid gives you a probability per element independently. If you need a whole distribution over classes that sums to 1, that's Ptf Softmax's job. Mixing the two up is the classic newbie slip - sigmoid for binary, softmax for multi-class.

    Where people get burned

    • Wiring it wrong: it's a callable, not a tensor op - it has no tensor input. Go through Pt Apply Function or a closure socket.
    • Expecting softmax behavior from sigmoid across a multi-class output. Different jobs, different nodes.
    • Numerical surprises: for very large logits, sigmoid saturates at exactly 1.0 - if that matters, consider the log-space sibling Ptf LogSoftmax.

    Installing it

    Part of ComfyUI-Pt-Wrapper:

    • ComfyUI Manager → search "ComfyUI-Pt-Wrapper" → Install → restart.
    • Or cd ComfyUI/custom_nodes && git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper and restart.

    Heavy dependency list (transformers, datasets, peft, accelerate, scikit-learn, scipy, gensim, sentencepiece), so the first install is slow. No model downloads needed. It's a niche educational pack by HowToSD with minimal community footprint - the repo's docs/reference/ is the authoritative reference.

    CategoryData Analysis

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    PTCALLABLEPTCALLABLE