Ptn GRU
A gated recurrent layer for sequence data
- PTMODEL
Ptn GRU is a Gated Recurrent Unit layer wrapped as a node in the HowToSD/ComfyUI-Pt-Wrapper pack, the direct equivalent of nn.GRU. It's a recurrent layer that reads sequences step by step while maintaining a hidden state, using gating to decide what to remember and what to forget. The GRU is LSTM's lighter, cheaper cousin - similar capability for sequential data, fewer parameters, less finicky to train. If your task involves order - text, time series, anything sequential - this is the layer that models it.
Why you'd reach for it
Recurrent layers are how you make a network respect sequence. Unlike a feedforward layer, a GRU sees each element of the sequence in context of everything before it, which is exactly what text classification needs. This node gives you the raw recurrent layer so you can assemble it into a custom model with Ptn Chained Model, or pair it with a linear head yourself. It's also the foundation the fancier Ptn GRU Linear node builds on - that one is GRU plus mean-pooling plus classifier, which you'd pick instead if all you want is a text classifier. Reach for the bare Ptn GRU when you want the recurrent layer under your own control.
How it works
It's nn.GRU with one pack-specific quirk called out in the docs: batch_first defaults to True here, unlike PyTorch's own GRU. So your input is (batch, seq, features), not (seq, batch, features). The node emits a PTMODEL whose forward returns the full output sequence (not just the last hidden state - the pack's GRU Linear node handles extracting what it needs). num_layers stacks multiple GRU layers; dropout applies between stacked layers only, so it's a silent no-op with num_layers = 1. bidirectional runs a second GRU backward and concatenates, which often helps classification but doubles the hidden state width.
The inputs
- input_size - features per time step.
- hidden_size - hidden state width; your main capacity dial.
- num_layers (default 1) - stacked layers.
- bias (on), batch_first (on - see above), dropout (0), bidirectional (off).
Output: PTMODEL.
Installing the pack
In the "Training" category. Install via ComfyUI Manager (search "ComfyUI-Pt-Wrapper") or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Restart ComfyUI. Install pulls in transformers, datasets, peft, scikit-learn, gensim and more; no model downloads at install.
Common issues
- batch_first trap - if you feed
(seq, batch, features)data because you're used to PyTorch's default, the model silently trains on transposed data. This pack flips the default; match your tensor to the flag. - Dropout no-op - with one layer, dropout does nothing. If you set it expecting regularization, raise
num_layersor don't bother. - Bidirectional dimension math - with
bidirectionalon, hidden state width doubles; any layer you chain after it must expecthidden_size * 2inputs. - Sequence length handling - the GRU itself handles variable lengths fine; the pack's pooling/linear helpers expect consistent shapes, so pad or truncate to a fixed length upstream.
- Thin support - single-author educational pack, nearly invisible on r/comfyui. The repo's RNN training doc is your best walkthrough.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| input_size | INT | 11–1000000 | — |
| hidden_size | INT | 11–1000000 | — |
| num_layers | INT | 11–1000 | — |
| bias | BOOLEAN | true | — |
| batch_first | BOOLEAN | true | — |
| dropout | FLOAT | 0.0000–1 | — |
| bidirectional | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| PTMODEL | PTMODEL | — |