chipiron.scripts.learn_nn_supervised package

Submodules

chipiron.scripts.learn_nn_supervised.learn_nn_from_supervised_datasets module

This script learns a neural network (NN) from a supervised dataset of board and evaluation pairs.

The script takes care of setting up the data loader from the evaluation files, creating the NN, and running the learning process.

Usage: - Instantiate the LearnNNScript class with a base_script object. - Call the run() method to start the learning process. - Call the terminate() method to finish the script.

Example

base_script = Script() learn_script = LearnNNScript(base_script) learn_script.run() learn_script.terminate()

class chipiron.scripts.learn_nn_supervised.learn_nn_from_supervised_datasets.LearnNNScript(base_script: Script[LearnNNScriptArgs])[source]

Bases: object

Script that learns a NN from a supervised dataset pairs of board and evaluation

Parameters:

base_script (Script) – The base script object.

Variables:
  • base_script (Script) – The base script object.

  • nn (ChiNN) – The neural network object.

  • args (LearnNNScriptArgs) – The script arguments.

args: LearnNNScriptArgs
args_dataclass_name

alias of LearnNNScriptArgs

base_experiment_output_folder = 'chipiron/scripts/learn_nn_supervised/learn_nn_supervised_outputs'
base_script: Script[LearnNNScriptArgs]
nn: ChiNN
nn_board_evaluator: NNBoardEvaluator
print_and_log_metrics(count_train_step: int, training_loss: float, test_error: float) None[source]

Print and log training metrics to console and MLflow.

Parameters:
  • count_train_step (int) – Current training step count.

  • training_loss (float) – Current training loss value.

  • test_error (float) – Current test error value.

Returns:

None

run() None[source]

Running the learning of the NN.

This method performs the training of the neural network. It iterates over the training data batches, computes the training loss, and updates the learning rate if necessary. It also prints the training loss and learning rate at regular intervals, and saves the learning process.

Returns:

None

saving_folder: str | PathLike[str]
saving_things_to_file(count_train_step: int, X_train: Tensor) None[source]

Saves the neural network parameters and trainer to file.

Parameters:

count_train_step (int) – The current training step count.

Returns:

None

terminate() None[source]

Finishing the script. Profiling or timing.

class chipiron.scripts.learn_nn_supervised.learn_nn_from_supervised_datasets.LearnNNScriptArgs(base_script_args: ~chipiron.scripts.script_args.BaseScriptArgs = <factory>, nn_trainer_args: ~chipiron.learningprocesses.nn_trainer.factory.NNTrainerArgs = <factory>, dataset_args: ~chipiron.players.boardevaluators.datasets.datasets.DataSetArgs = <factory>)[source]

Bases: object

Represents the arguments for the LearnNNScript.

Variables:

nn_trainer_args (NNTrainerArgs) – The arguments for the NNTrainer.

base_script_args: BaseScriptArgs
dataset_args: DataSetArgs
nn_trainer_args: NNTrainerArgs

Module contents