Pt Squeeze
Drop the pointless size-1 dimensions
- tens
- TENSOR
Pt Squeeze removes dimensions of size 1 from a tensor. It's the cleanup node for the shape noise that training workflows generate: a model that adds a channel axis when you didn't want one, a batch dimension that's always 1 because you're processing one sample at a time, a tensor that's technically (1, 1, 96, 96) when you just want (96, 96). If the data is fine but the shape has pointless singleton dimensions, squeeze is the fix.
What it actually does
It's a wrapper around torch.squeeze(tens, dim). One TENSOR in, one TENSOR out. The key input is dim, an integer (default -1, range -1 to 10) that says which dimension to remove - and it only removes that dimension if it has size 1. That last part is the important behavior: if the dimension you name isn't size 1, the tensor passes through unchanged. No error, no crash - you just get the same tensor back. That makes it safe to leave in a workflow even when you're not sure the dimension exists.
The default of -1 is a bit of a trap: -1 refers to the last dimension. So by default this node tries to squeeze the final axis, which is size 1 only in specific cases. If you're squeezing a channel or batch axis in the middle of a tensor, set dim explicitly. The docstring notes that specifying multiple dimensions at once (a tuple) isn't supported yet - one dimension at a time, so chain the node if you need two squeezes.
Only the two inputs:
- tens - the tensor to squeeze.
- dim - which dimension to drop if it's size 1.
Output is a single TENSOR.
How to install it
It's part of the ComfyUI-Pt-Wrapper pack. ComfyUI Manager: search ComfyUI-Pt-Wrapper, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Restart after. The pack's requirements.txt is the heavy training stack (transformers, datasets, accelerate, peft, gensim, sentencepiece, pandas, scikit-learn, scipy) - slow first install, possible conflicts with other nodes.
Gotchas
The default dim = -1 catches people because it acts on the last axis, not "any axis." If you expect this node to remove every size-1 dimension (like the no-arg version of torch.squeeze() does), you'll be surprised when only the last one goes. Set the dim explicitly.
And remember the pass-through behavior: naming a dimension that isn't size 1 is not an error, so a "squeeze that did nothing" is often just a dim choice that doesn't match the tensor. Check the actual shape with Pt Size or Pt Show Size when in doubt.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| tens | TENSOR | — | |
| dim | INT | -1-1–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |