Load Array → DataLoader
The bridge from raw tensors to a trainable dataset
- features
- labels
- dataloader
Almost every deep-learning workflow in ComfyDL funnels through the same bottleneck: at some point your data has to become a PyTorch DataLoader, because that's the object every training and evaluation loop consumes. CdlLoadArray is the generic bridge. It takes feature and label tensors - whatever you synthesized or preprocessed upstream - and wraps them into a proper batched, shuffleable DataLoader. Think of it as the converter every synthetic-data experiment needs.
Its natural partner is ComfyDL's synthetic-data generator: the pack's linear-regression demo builds tensors, pipes them through this node, and suddenly you're training a model on data that never touched disk. If you're experimenting with any cdlTensor you generated by hand, this is how it gets fed to the machinery.
How it works
Under the hood it uses the d2l load_array helper, which is a one-two punch: torch.utils.data.TensorDataset pairs up your feature and label tensors element-wise, and a standard DataLoader iterates over them in batches. The shuffle toggle maps straight onto the DataLoader's shuffle flag. Nothing is copied needlessly - the loader reads from the tensors you already have - so it's cheap to build and rewire.
One design detail worth knowing: shuffle and batch_size are the required inputs, while features and labels are optional sockets. You can load features alone (useful for unsupervised-style demos) or features plus labels (the usual case for supervised learning). But connect at least one - if you leave both empty the node refuses with a clear "at least one of features or labels must be connected" error.
Inputs and outputs that matter
batch_size(default 32, up to 4096) - samples per batch.shuffle(default true) - randomize order every epoch. True for training, false for evaluation, so you don't get misleading metrics.features(optionalcdlTensor) - your input tensors, typically(num_samples, num_features).labels(optionalcdlTensor) - the targets, usually(num_samples, 1)for regression.
The dataloader output (cdlDataloader) then plugs into ComfyDL's DataLoader Info, DataLoader Preview, or Dataset Stats nodes for inspection, and into the training utilities when you're ready.
Installing ComfyDL
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL ./ComfyDL
pip install -r ./ComfyDL/requirements.txt
Restart ComfyUI afterwards. Dependencies are light (matplotlib, IPython, matplotlib-inline) and there are no model or dataset downloads - you're providing the tensors. ComfyUI Manager may not list this young pack; cloning is the dependable install.
Gotchas
Shape agreement is the thing to check before you wonder why training is nonsense: features and labels must have the same leading dimension (same number of samples), and each must be 2D as ComfyDL's tensor nodes produce them. Feed a label tensor shaped (samples,) when the pipeline expects (samples, 1) and TensorDataset will throw a size-mismatch that names neither tensor - so when in doubt, reshape. And remember shuffle=true is what your training split wants; leave the toggle on for the demo DataLoaders and flip it only for evaluation.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| batch_size | INT | 321–4096 | — |
| shuffle | BOOLEAN | true | — |
| featuresopt | cdlTensor | — | |
| labelsopt | cdlTensor | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| dataloader | cdlDataloader | — |