Nodes/ComfyUI-Pt-Wrapper/Pt Data Loader From Tensors
ComfyUI Node

Pt Data Loader From Tensors

Skip the dataset, feed raw tensors straight to training

By HowToSD·Created about a year ago·Updated about a year ago· 7
Pt Data Loader From Tensors
  • x
  • y
  • PTDATALOADER
batch_size1
shufflefalse

Pt Data Loader From Tensors is the shortcut version of Pt Data Loader. Where its sibling expects a dataset object built by a Ptv Dataset-style node, this one takes two raw tensors - features and labels - and turns them straight into a PyTorch DataLoader. If your data already lives in tensor form, this is the node you reach for. It's the difference between mounting a file system and just handing someone the files.

How it works

The mechanism is about as simple as it gets: the node builds a TensorDataset from your x and y tensors and wraps it in a DataLoader with your batch size and shuffle setting. TensorDataset pairs the two tensors element-wise along the first dimension, so row i of x is the input and row i of y is its label. The resulting PTDATALOADER output plugs into any training node - Pt Train Model, the classification trainers, regression trainers - exactly like the output of the regular Data Loader node.

This is the node to use with things like Pt Float Create or Pt Arange for synthetic data experiments, or Pt From Image when you've already built your feature tensor and want to label it with a matching y.

The inputs that matter

  • x - the feature tensor. Shape (n_samples, ...).
  • y - the label tensor. It must match x on the first dimension: y.shape[0] == x.shape[0]. That's the number of samples, and if the two disagree, TensorDataset will throw.
  • batch_size - integer, default 1. Raise it to train in proper mini-batches.
  • shuffle - boolean, default off. On for training, off for evaluation.

Like its sibling, this node forces an uncached re-run every execution, which is what you want here.

Where people get burned

The classic failure is shape mismatch between x and y. Get the first dimension right and almost everything else takes care of itself. A second, subtler one: this is the raw tensors loader, so if you feed it a PTVDATASET by mistake (or vice versa), the sockets simply won't connect - this node wants TENSOR, not a dataset object. And since the pack lets you wire almost anything anywhere if you're not careful, double-check the pink socket color before you panic about a mystery type error.

Installing it

It ships in ComfyUI-Pt-Wrapper, so installation is the whole-pack affair:

  • ComfyUI Manager → search "ComfyUI-Pt-Wrapper" → Install → restart.
  • Or cd ComfyUI/custom_nodes && git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper and restart.

The pack pulls in a big dependency list (transformers, datasets, peft, accelerate, scikit-learn, scipy, gensim, sentencepiece...), so give the first startup after install some patience. No model files are needed for this node - just tensors in, DataLoader out.

The pack is a niche, education-flavored tool by HowToSD (a solo tutorial author), and you won't find much troubleshooting chatter about it on Reddit. When in doubt, the node reference in the repo's docs/reference/ is the authoritative doc, and the README welcomes issues.

CategoryTraining

Inputs (4)

NameTypeDefaultDescription
xTENSOR
yTENSOR
batch_sizeINT11–1000000
shuffleBOOLEANfalse

Outputs (1)

NameTypeDescription
PTDATALOADERPTDATALOADER