Ptn Linear Model
Dim_list in, classifier out
- PTMODEL
If PtnLinear is one dense layer, this is the entire multi-layer perceptron in a single node. You type a list of dimensions, it builds the whole stack, and you get a ready-to-train PTMODEL. For the pack's canonical use case - MNIST/Fashion-MNIST classification with a 784-pixel input - this is the node from the fashion_mnist_train.json workflow. When you want to test an MLP baseline before reaching for a conv net or transformer, this is the fastest way to stand one up.
How it works
PtnLinearModel builds a DenseModel: every hidden layer is nn.Linear followed by a ReLU activation, and the final layer is a bare nn.Linear with no activation - you're expected to pair it with a loss that brings its own, like Ptn BCE With Logits Loss or Ptn Cross Entropy Loss. Internally it also flattens the input (inputs.view(-1, dim_list[0])) before the first layer, which saves you a separate flattening step as long as your input's feature count matches dim_list[0].
The inputs that matter
- dim_list (default
"[784,10]") - a Python-list string of dimensions. It holds the input size first, then each layer's output size.[784,128,10]means input 784, hidden 128, output 10. The list is always one element longer than the number of layers. - bias_list (default
"[True]") - a string list ofTrue/False, one per layer, controlling bias on each dense layer. - num_layers (default
1) - how many layers to build. Must satisfylen(dim_list) - 1 == num_layers, or the node throws a validation error telling you exactly that.
Output is a single PTMODEL. Note the string-vs-int gotcha: you're typing "[784,10]" with brackets, not 784,10 - the node ast.literal_evals the string, so malformed lists are a runtime error.
How you'd use it
The Fashion-MNIST example chains PtnPreFlatten before this node so 28×28 images arrive as 784-vectors, then feeds the model into Pt Train Classification Model with an optimizer, a loss, and Pt Save Model on the output. For a quick experiment, [784,128,10] with num_layers=2 and bias_list=[True,True] is a sensible two-layer start.
Installing
Standard for the pack. ComfyUI Manager → search "Pt-Wrapper", or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Restart. First launch installs the pack's heavy requirements (scikit-learn, pandas, transformers, etc.) - slow once, fine after.
Where people get burned
Nearly every failure is a list/count mismatch: dim_list shorter than num_layers + 1, or bias_list the wrong length. The node is good about raising a clear ValueError, but the fix is on you. Also remember hidden layers all get ReLU, so if you wanted a different activation (or none) you'd chain individual PtnLinear layers instead of using this convenience node.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| dim_list | STRING | [784,10] | — |
| bias_list | STRING | [True] | — |
| num_layers | INT | 11–2000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| PTMODEL | PTMODEL | — |