ComfyUI Node

Activation

Stick a ReLU (or any activation) on the end of your PyTorch model without leaving the graph

By TashaSkyUp·Created about a year ago·Updated about a year ago· 1
Activation
  • model
  • TORCH_MODEL
activation

The Activation node does exactly one thing: it picks an activation function and appends it to the end of a PyTorch nn.Sequential model you're building in ComfyUI. ReLU is the boring default and it's the boring default for a reason - but if you're building a classifier and want the output squeezed into 0–1, or a network where tanh or SiLU genuinely helps, this is the knob.

This pack (EternalKernel PyTorch Nodes) is a small, niche family of nodes for assembling and training real torch.nn models in the ComfyUI graph - think "machine learning playground," not image generation. If you've already got an empty model from SequentialModelProvider and you're stacking AddLinearLayerNode blocks, this is the node you reach for between them (nonlinearity after each linear layer is what makes the stack more than one giant linear operation) or at the very end.

How it works

Under the hood it's two lines: the activation dropdown is populated live from every public class in torch.nn.modules.activation - so ReLU, Sigmoid, Tanh, Softmax, LeakyReLU, GELU, SiLU, and friends, roughly 40 of them - and the node instantiates whatever you picked and does model.insert(...) to push it onto the end of the Sequential. Your model is mutated in place and handed back out.

One thing to know: the menu you see is generated from your installed torch. The list reflects your PyTorch version, so if you notice a few activations missing compared to a tutorial someone wrote on torch 2.1, that's the pack faithfully reading your environment, not a bug.

Inputs and output

Only two things matter here:

  • model (TORCH_MODEL) - the Sequential you're extending. Feed it the output of SequentialModelProvider or any other ETK layer-builder node.
  • activation - the dropdown. Type to search; the list is big and alphabetized.

It returns a single TORCH_MODEL out, which you chain into the next layer node or into TrainModel/PyTorchInferenceNode.

Install

From ComfyUI Manager, search "EternalKernel PyTorch Nodes" and install. Or, manually:

cd ComfyUI/custom_nodes
git clone https://github.com/TashaSkyUp/EternalKernelPytorchNodes
cd EternalKernelPytorchNodes
pip install -r requirements.txt

Restart ComfyUI after installing, and you'll find the node under ETK/pytorch. The heavy deps (torch, torchvision, numpy) are already in any working ComfyUI env; the requirements file mainly adds scipy, scikit-learn, transformers, and einops, which you may or may not already have.

Common issues

  • "model is not an nn.Sequential" error. Every layer-builder node in this pack insists on a Sequential. If you didn't start from SequentialModelProvider (or a model this pack built), you'll hit this. Build from the pack's own provider and you're fine.
  • Don't expect the model to change shape. An activation maps values, it doesn't change tensor dimensions. If your next layer's in_features no longer matches, that's a mismatch you introduced elsewhere, not this node.
  • Silent-wire gotcha that's pack-wide: this pack patches ComfyUI's input validation on load to ignore return_type_mismatch errors, so a wrongly-typed connection may no longer pop up as an error. Worth knowing before you chase a "why is my output wrong" ghost - check the wire types yourself.

One honest caveat: this pack has essentially no community footprint - no tutorials, no threads, nobody's workflow included. You're a pioneer. The upside is the nodes are thin wrappers around stock torch, so what you learn here transfers 1:1 to PyTorch itself.

CategoryETK/pytorch

Inputs (2)

NameTypeDefaultDescription
modelTORCH_MODEL
activationCOMBO40 options: warnings, Optional, torch, F, Tensor, constant_, +34

Outputs (1)

NameTypeDescription
TORCH_MODELTORCH_MODEL