DatsetSplitter
Carve an 80/20 train/validation split out of your dataset
- dataset
- train_ds
- val_ds
Every honest ML workflow needs a hold-out set: you train on one chunk and check on data the model never saw, so you can tell learning from memorizing. DatsetSplitter (the misspelling is the actual node name - one "a", deal with it) is the pack's way to do that: it takes a TORCH_DATASET and uses PyTorch's random_split to carve it into two - a fixed 80% train set and 20% validation set. Two outputs, no ratio knob.
You reach for it right after downloading a dataset and before training: dataset → splitter → train_ds into TrainModel, val_ds kept aside for honest evaluation. In a pack whose TrainModel doesn't even expose a validation split of its own, this node is the validation story - which makes it one of the more useful data nodes here.
How it works
It computes int(len * 0.8) for train and int(len * 0.2) for val, then calls random_split, which returns two torch.utils.data.Subset views over the original data - no copies, and each run shuffles the partition anew (there's no seed control exposed). The outputs are train_ds and val_ds, both typed TORCH_DATASET, so they feed straight into training or inference nodes.
Inputs and outputs
- dataset (
TORCH_DATASET) - a raw dataset fromPyTorchDatasetDownloader, orTensorsToDataset. - Outputs: train_ds and val_ds (
TORCH_DATASETeach).
Install
ComfyUI Manager, search "EternalKernel PyTorch Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/TashaSkyUp/EternalKernelPytorchNodes
cd EternalKernelPytorchNodes
pip install -r requirements.txt
Restart ComfyUI; node under ETK/pytorch. No model files. Requirements are the standard ComfyUI stack plus scipy, scikit-learn, transformers, einops.
Common issues
- The ratio is fixed at 80/20 and there's no seed. If you need a different split or reproducible splits, this node isn't it -
random_split's default behavior is what you get, and a fresh random partition every queue. For reproducibility you'd want a seeded splitter from another pack. - Subset outputs are views.
train_dsandval_dsreference the original dataset's data. They don't copy - which is efficient, but also means you can't independently mutate one. FlattenDatasetwon't take these. The splitter returnsSubsetobjects, which have no.dataattribute - a known incompatibility with the pack'sFlattenDataset(which needs the raw dataset). Flatten before you split.- Very small datasets. 20% of a 10-sample dataset is 2 samples - a degenerate validation set. Below a few hundred samples, splits get noisy; that's a data problem, not a node problem.
The misspelled name is a tiny warning sign of the pack's polish level overall, but the mechanics here are stock random_split, so behavior is predictable. Pack-wide quirk: it patches ComfyUI's validator to ignore return_type_mismatch, so mismatched wires may not flag themselves. And as with everything here - no tutorials, no community threads; the source file is the documentation.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| dataset | TORCH_DATASET | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| train_ds | TORCH_DATASET | — |
| val_ds | TORCH_DATASET | — |