Nodes/ComfyUI-Pt-Wrapper/Ptdm Log Prob Tensor
ComfyUI Node

Ptdm Log Prob Tensor

Ptdm Log Prob Tensor — score a whole tensor against a distribution in one shot

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptdm Log Prob Tensor
  • distribution
  • tens
  • TENSOR

The scalar PtdmLogProb scores one value. PtdmLogProbTensor scores a whole tensor of values against your distribution in a single call - the version you actually want when you've sampled a batch and need the log-likelihood of every draw, or when you're feeding a loss computation. One wire, one call, whole batch handled.

It's part of ComfyUI-Pt-Wrapper, HowToSD's no-code PyTorch toolkit. It's the vectorized sibling in the Ptdm* family, and it's the one that shows up in real training workflows - computing negative log-likelihood over a batch of predictions is exactly the kind of thing you'd wire into the pack's loss machinery.

How it works

No parsing, no dtype sniffing - it calls distribution.log_prob(tens) directly and returns the result. The distribution handles whatever dtype your tensor carries, and the output keeps the input's shape. It's about as thin a wrapper as this pack ships; all the real behavior lives in the distribution you built with a Ptd* node.

Inputs that matter

  • distribution - a PTDISTRIBUTION from a Ptd* constructor.
  • tens - a TENSOR of values to score.

Output is a TENSOR of the same shape, filled with log-probabilities. Sum it with the pack's tensor-math nodes and you've got a total log-likelihood for a whole dataset - a genuinely useful statistic you'd otherwise have to code.

Installing it

Standard pack install: ComfyUI Manager → "Pt Wrapper" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper

Restart ComfyUI after. First install is slow because the pack pulls a big stack (matplotlib, pandas, scipy, scikit-learn, transformers, datasets, pinned gensim), but this node needs nothing extra.

Common issues

The outputs are logs, so expect negative values and -inf wherever the distribution assigns zero probability - that's the feature, not a bug. If your tensor mixes dtypes, cast it with the pack's PtToFloat32 or similar before scoring; a discrete distribution scored on a float tensor is a mismatch waiting to bite. And as always in this family, if you see NotImplementedError, the distribution you're using wasn't one of the pack's patched constructors.

CategoryDistribution

Inputs (2)

NameTypeDefaultDescription
distributionPTDISTRIBUTION
tensTENSOR

Outputs (1)

NameTypeDescription
TENSORTENSOR