Pt Pow
Pt Pow raises one tensor to the power of another
- tens_a
- tens_b
- TENSOR
PtPow is the node version of torch.pow(): it raises every element of one tensor to the power of the corresponding element of another, element-wise. It's one of the pack's arithmetic-operation nodes - the same family as Pt Add, Pt Mul, Pt Div - and it's the piece you reach for when your math needs a square, a cube, a reciprocal, or a fractional exponent somewhere in the middle of a graph.
How it works
Two tensor inputs, one tensor output:
- tens_a - the base tensor, any shape.
- tens_b - the exponent tensor. The output is
tens_a ** tens_belement-wise, so broadcasting applies: iftens_bis a scalar-shaped tensor (or broadcasts to match), every element oftens_agets raised to that power.
Both plug in as the pack's TENSOR type. Output is another TENSOR you can chain into any Pt* node. If you want a plain square or cube, you can generate a scalar tensor with a constant node and use that as tens_b - or, more idiomatically in this pack, wire in whatever tensor your pipeline already computed.
When you'd actually use this
Honest cases: squaring values for variance-style math (that's what the pack's own distribution/statistics workflows do under the hood), computing reciprocal squares, scaling or decaying curves element-wise, or applying a polynomial term in a synthetic-data pipeline. It's a math building block, not a headline node - you'll rarely place it alone, but it's the missing piece in plenty of graphs. Think "I need x² in the middle of my tensor pipeline" and you've found your node.
The gotcha to keep in mind
Negative or fractional bases with non-integer exponents get you into NaN territory fast - that's standard IEEE float behavior, not a pack bug. If tens_a contains negative values and tens_b is a fractional tensor, expect NaNs. Also remember this is element-wise and follows broadcasting rules: tens_a and tens_b don't need identical shapes, but they do need to be broadcast-compatible, and when they're not you'll get a runtime shape error rather than a friendly hint. For the record, you can also just use a scalar for tens_b via the pack's Pt Float Create node - a very common pattern.
Installing it
Part of ComfyUI-Pt-Wrapper (HowToSD's no-code PyTorch pack, a spin-off of ComfyUI-Data-Analysis). ComfyUI Manager → search "ComfyUI-Pt-Wrapper", or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Restart after; first boot is slow while pandas, scikit-learn, transformers, sentencepiece, peft and friends install. No model downloads needed.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| tens_a | TENSOR | — | |
| tens_b | TENSOR | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |