NNT Training Hyperparameters
Bundle your training settings into one reusable dict
- training_params
- config_summary
NntTrainModel has so many knobs - optimizer, scheduler, early stopping, class weights - that the node itself is a wall of dropdowns. NNT Training Hyperparameters is the answer to that: it collects every one of those settings into a single DICT, bundles it with a name and a summary, and lets you plug the whole configuration into a training node in one wire. Think of it as the "save my experiment settings as a thing" node.
It exists because NntTrainModel accepts an optional hyperparameters input of type DICT that overrides its built-in settings. This node is the cleanest way to build that dict. Same settings, one reusable package instead of twenty fields.
What it holds
The node exposes all the classic training knobs: experiment_name, batch_size (default 32), epochs (default 10), optimizer (12 choices, default Adam), learning_rate (default 0.001), weight_decay, momentum, loss_function (21 choices, default CrossEntropyLoss), reduction, optional class_weights (as a string list like [0.5, 1.0]), margin (for margin-based losses), and the scheduler block - use_lr_scheduler, scheduler_type (StepLR / ReduceLROnPlateau / CosineAnnealingLR), scheduler_step_size, scheduler_gamma, min_lr - plus early stopping (use_early_stopping, patience, min_delta).
Outputs: training_params (the DICT - wire this into NntTrainModel's hyperparameters input) and config_summary (a readable string of everything you set, which is great for a text display node or for screenshotting an experiment config for a writeup).
How to use it, and one honest caveat
Build a hyperparameters node, set your optimizer/epochs/lr, wire training_params into the hyperparameters input of NntTrainModel, and run. The override means whatever you set here wins over the train node's own fields - the code literally does locals().update(hyperparameters.get('training', {})) at the start of training. That's the feature, and also the trap: if you change a setting on the train node itself and forget the hyperparameters node is still wired in, your change silently does nothing. When experiments aren't behaving, check for a stray hyperparameters wire first.
The natural workflow here is experimentation: build two hyperparameter bundles (say, Adam vs SGD, or lr 1e-3 vs 1e-4), and switch between them by rewiring one input instead of resetting twenty fields. For a learning pack, that's a nice way to make "hyperparameter tuning" concrete - change one bundle, watch the metrics move.
Install
Pack-level install:
cd ComfyUI/custom_nodes
git clone https://github.com/inventorado/ComfyUI_NNT.git
cd ComfyUI_NNT
pip install -r requirements.txt
Restart ComfyUI, or install via Manager by searching "ComfyUI Neural Network Toolkit NNT". No extra dependencies beyond what the pack already needs (torch, sklearn, matplotlib, statsmodels, onnx, shap 0.41.0, and the rest - slow first install, as always with this pack).
One last note: this node is purely a configuration builder - it doesn't train anything itself. Its training_params dict only has meaning inside NntTrainModel. If you wire it into anything else, it's just a dict of settings looking for a home.
Inputs (20)
| Name | Type | Default | Description |
|---|---|---|---|
| experiment_name | STRING | training_experiment | — |
| batch_size | INT | 321–512 | — |
| epochs | INT | 101–1000 | — |
| optimizer | COMBO | Adam | 12 options: Adadelta, Adagrad, Adam, AdamW, SparseAdam, Adamax, +6 |
| learning_rate | FLOAT | 0.00100.000001–1 | — |
| weight_decay | FLOAT | 0.00010–0.1 | — |
| momentum | FLOAT | 0.90–1 | — |
| loss_function | COMBO | CrossEntropyLoss | 21 options: L1Loss, MSELoss, CrossEntropyLoss, CTCLoss, NLLLoss, PoissonNLLLoss, +15 |
| reduction | COMBO | mean | 3 options: mean, sum, none |
| weight_enabled | COMBO | False | 2 options: True, False |
| class_weights | STRING | [] | — |
| margin | FLOAT | 0.0-1–1 | — |
| use_lr_scheduler | COMBO | True | 2 options: True, False |
| scheduler_type | COMBO | ReduceLROnPlateau | 3 options: StepLR, ReduceLROnPlateau, CosineAnnealingLR |
| scheduler_step_size | INT | 31–100 | — |
| scheduler_gamma | FLOAT | 0.100.01–1 | — |
| min_lr | FLOAT | 0.00001e-7–0.1 | — |
| use_early_stopping | COMBO | True | 2 options: True, False |
| patience | INT | 51–50 | — |
| min_delta | FLOAT | 0.00100.0001–0.1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| training_params | DICT | — |
| config_summary | STRING | — |