AI::MXNet::Callback - A collection of predefined callback functions.
A collection of predefined callback functions, mainly to be used in AI::MXNet::Module::Base::fit.
my $model = mx->mod->Module( symbol => $net, context => $contexts ); $model->fit( $data_iter, eval_metric => mx->metric->Perplexity, kvstore => $kv_store, optimizer => $optimizer, optimizer_params => { learning_rate => $lr, momentum => $mom, wd => $wd, clip_gradient => 5, rescale_grad => 1/$batch_size, lr_scheduler => AI::MXNet::FactorScheduler->new(step => 1000, factor => 0.99) }, initializer => mx->init->Xavier(factor_type => "in", magnitude => 2.34), num_epoch => $num_epoch, batch_end_callback => mx->callback->Speedometer($batch_size, $disp_batches), ($chkp_epoch ? (epoch_end_callback => [mx->callback->module_checkpoint($model, $chkp_prefix, $chkp_epoch), \&sample]) : ()) );
Callback to save the module setup in the checkpoint files. Parameters ---------- $mod : subclass of AI::MXNet::Module::Base The module to checkpoint. $prefix : Str The file prefix to checkpoint to $period=1 : Int How many epochs to wait before checkpointing. Default is 1. $save_optimizer_states=0 : Bool Whether to save optimizer states for later training. Returns ------- $callback : sub ref The callback function that can be passed as iter_end_callback to fit.
Callback to log the training evaluation result every period. Parameters ---------- $period : Int The number of batches after which to log the training evaluation metric. $auto_reset : Bool Whether to reset the metric after the logging. Returns ------- $callback : sub ref The callback function that can be passed as iter_epoch_callback to fit.
AI::MXNet::Speedometer - A callback that logs training speed
Calculate and log training speed periodically. Parameters ---------- batch_size: int batch_size of data frequent: int How many batches between calculations. Defaults to calculating & logging every 50 batches. auto_reset: Bool Reset the metric after each log, defaults to true.
AI::MXNet::ProgressBar - A callback to show a progress bar.
Shows a progress bar. Parameters ---------- total: Int batch size, default is 1 length: Int the length of the progress bar, default is 80 chars
AI::MXNet::LogValidationMetricsCallback - A callback to log the eval metrics at the end of an epoch.
To install AI::MXNet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AI::MXNet
CPAN shell
perl -MCPAN -e shell install AI::MXNet
For more information on module installation, please visit the detailed CPAN module installation guide.