Ptn Conv 2d
The single convolutional layer node
- PTMODEL
Ptn Conv 2d is a single 2D convolution layer exposed as a node in the HowToSD/ComfyUI-Pt-Wrapper pack. Give it input and output channel counts, a kernel size, and a stride, and it returns a PTMODEL that slides a learned filter bank over your (batch, channels, height, width) tensors. It's the fundamental building block of image models - if you're assembling a CNN by hand instead of grabbing the pre-built Ptn Conv Model, this is the layer you'll stack.
Why you'd reach for it
Convolutions are how image models find spatial structure: a small kernel looks at a local neighborhood, learns a feature detector, and shares that detector across the whole image. The single-layer node matters for two reasons. First, composition - chain a few of these (with batch norm and activations between them) into a custom network, and you've designed your own architecture. Second, the last layer of many image classifiers is a convolution tuned down to one channel, or you want just one conv on top of an existing feature map. The author's "build a model from scratch" workflow is basically this node plus a few friends, chained.
How it works
It's nn.Conv2d wrapped with sensible defaults. kernel_size, stride, padding, and dilation are text fields that accept either an integer ("3") or a tuple ("(3, 5)"), so you can have asymmetric kernels. padding also accepts the strings "same" and "valid" directly, which PyTorch interprets as "preserve spatial size" and "no padding" - the default is "same", which means with stride 1 your feature maps keep their size. padding_mode picks how padding values are filled (zeros, reflect, replicate, circular). The output is a PTMODEL layer to assemble into a network; it rebuilds on every graph run.
The inputs
- in_channels / out_channels - channels in, channels out. Match
in_channelsto whatever the previous layer emitted. - kernel_size (default
"3") - filter size;"3"or"(3, 5)". - stride (default
"1") - how far the kernel steps. - padding (default
"same") -"same","valid", or a number. - dilation (default
"1") - spacing between kernel elements (dilated convs expand the receptive field). - groups (default 1) - split channels into groups processed separately (depthwise convs use
groups = in_channels). - bias (default on) - add a learnable bias.
- padding_mode - how padding fills (
zerosdefault).
Output: PTMODEL.
Installing the pack
In the "Training" category of the pack. Install via ComfyUI Manager (search "ComfyUI-Pt-Wrapper") or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Restart ComfyUI. The pack's requirements.txt brings in transformers, datasets, peft, scikit-learn, gensim and more; no model downloads at install.
Common issues
- Channel mismatch -
in_channelsmust equal the previous layer'sout_channels, or the forward pass errors. Double-check when chaining. - String parse errors - kernel/stride/padding/dilation must be valid literals:
"3"or"(3, 3)", never"3, 3". - "same" padding gotchas - with
"same"and stride 2, PyTorch computes padding automatically and output size halves; with odd kernels the padding is uneven. Verify output shape with Pt Show Size if spatial sizes matter downstream. - Community is thin - this is a single-author educational pack with nearly zero r/comfyui or r/StableDiffusion footprint. The repo's node reference and model-training docs are your best help.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| in_channels | INT | 11–1000000 | — |
| out_channels | INT | 11–1000000 | — |
| kernel_size | STRING | 3 | — |
| stride | STRING | 1 | — |
| padding | STRING | same | — |
| dilation | STRING | 1 | — |
| groups | INT | 11–1000000 | — |
| bias | BOOLEAN | true | — |
| padding_mode | COMBO | 4 options: zeros, reflect, replicate, circular |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| PTMODEL | PTMODEL | — |