--batch-size

๐Ÿฆ‰ AthenaAI is an AI-powered ensemble machine-learning trading bot for PocketOption, built on BinaryOptionsToolsV2 โ†’ Get it on GitLab
๐Ÿ’ฌ Need help? Join the Chipa Discord ยท โšก Go no-code with ChipaEditor

Mini-batch size used when training the neural model.

Typeint (samples per batch)
Default2048
Maps toTrainerConfig.nn_batch_size
Read intrain.py โ†’ src/training/trainer.py (Trainer._train_nn()) โ†’ src/training/torch_model.py (TorchMLPClassifier.fit())

What it does

_train_nn() passes nn_batch_size to TorchMLPClassifier(batch_size=...). In fit(), the training data becomes a TensorDataset wrapped in a DataLoader(ds, batch_size=self.batch_size, shuffle=True); each optimizer step processes one batch, moved to the training device (cuda/mps/cpu). Shuffling happens within the training set only โ€” the chronological train/holdout split from --test-split already happened, so no future data leaks in.

Batch size affects only the neural model; the sklearn online models use their own fixed chunk size (TrainerConfig.online_batch = 5000, not CLI-exposed).

Choosing a value

  • Larger batches mean fewer optimizer steps per epoch (faster on GPU) but more GPU memory per step; the loss-visible effect of fewer, less noisy gradient updates can also change what learning rate works best.
  • CUDA out of memory: lower this first โ€” the training guide suggests e.g. --batch-size 512 โ€” or shrink --hidden. The feature vectors are small, so at the default 128,64 network even 2048 is light on modern GPUs; OOM usually indicates a very large --hidden.
  • On CPU, very large batches gain little; values in the 256โ€“2048 range are all reasonable.

Examples

python train.py --batch-size 512          # if you hit GPU out-of-memory
python train.py --batch-size 4096 --lr 2e-3

Interactions

  • --hidden โ€” the other memory-footprint knob.
  • --lr โ€” larger batches often tolerate/need a higher learning rate.
  • --no-nn โ€” makes this flag a no-op.
  • --cpu โ€” removes GPU memory limits from the equation.

See also

๐Ÿ’ฌ Unsure how this interacts with the rest of the configuration? Ask in the Chipa Discord โ€” or prototype strategies no-code with ChipaEditor.