Skip to content

mod_train_helpers

Lines: 265 | Visibility: private

Routines helpful during training. author: Alexander Knoll, Alea Tokita, Moritz R. Schaefer, Redouan El Haouari

Dependencies

Uses

module~~mod_train_helpers~~UsesGraph module~mod_train_helpers mod_train_helpers module~mod_abstract_property_model mod_abstract_property_model module~mod_train_helpers->module~mod_abstract_property_model module~mod_abstractoptimizer mod_abstractoptimizer module~mod_train_helpers->module~mod_abstractoptimizer module~mod_decorations mod_decorations module~mod_train_helpers->module~mod_decorations module~mod_global_warning mod_global_warning module~mod_train_helpers->module~mod_global_warning module~mod_io mod_io module~mod_train_helpers->module~mod_io module~mod_loss_abstract mod_loss_abstract module~mod_train_helpers->module~mod_loss_abstract module~mod_mpi mod_mpi module~mod_train_helpers->module~mod_mpi module~mod_periodic_table mod_periodic_table module~mod_train_helpers->module~mod_periodic_table module~mod_precision mod_precision module~mod_train_helpers->module~mod_precision module~mod_settings mod_settings module~mod_train_helpers->module~mod_settings module~mod_throw mod_throw module~mod_train_helpers->module~mod_throw module~mod_abstract_property_model->module~mod_io module~mod_abstract_property_model->module~mod_precision module~mod_abstract_property_model->module~mod_settings module~mod_abstract_property_model->module~mod_throw module~mod_array_helpers mod_array_helpers module~mod_abstract_property_model->module~mod_array_helpers module~mod_initialize_array mod_initialize_array module~mod_abstract_property_model->module~mod_initialize_array module~mod_random mod_random module~mod_abstract_property_model->module~mod_random module~mod_abstractoptimizer->module~mod_global_warning module~mod_abstractoptimizer->module~mod_io module~mod_abstractoptimizer->module~mod_loss_abstract module~mod_abstractoptimizer->module~mod_mpi module~mod_abstractoptimizer->module~mod_precision module~mod_abstractoptimizer->module~mod_settings module~mod_abstractoptimizer->module~mod_throw module~mod_gradient_clipping mod_gradient_clipping module~mod_abstractoptimizer->module~mod_gradient_clipping module~mod_nan_check mod_nan_check module~mod_abstractoptimizer->module~mod_nan_check module~mod_decorations->module~mod_io module~mod_decorations->module~mod_precision module~mod_decorations->module~mod_throw module~mod_global_warning->module~mod_io module~mod_global_warning->module~mod_throw module~mod_abstract_warning mod_abstract_warning module~mod_global_warning->module~mod_abstract_warning module~mod_io->module~mod_precision iso_fortran_env iso_fortran_env module~mod_io->iso_fortran_env module~mod_optional_args mod_optional_args module~mod_io->module~mod_optional_args module~mod_loss_abstract->module~mod_mpi module~mod_loss_abstract->module~mod_precision module~mod_mpi->module~mod_precision mpi_f08 mpi_f08 module~mod_mpi->mpi_f08 module~mod_periodic_table->module~mod_io module~mod_periodic_table->module~mod_precision module~mod_periodic_table->module~mod_throw module~mod_periodic_table->module~mod_array_helpers module~mod_constants mod_constants module~mod_periodic_table->module~mod_constants iso_c_binding iso_c_binding module~mod_precision->iso_c_binding module~mod_precision->iso_fortran_env module~mod_settings->module~mod_io module~mod_settings->module~mod_periodic_table module~mod_settings->module~mod_precision module~mod_settings->module~mod_throw module~mod_settings->module~mod_constants module~mod_cpu_vendor mod_cpu_vendor module~mod_settings->module~mod_cpu_vendor module~mod_throw->module~mod_io module~mod_throw->module~mod_mpi module~mod_throw->module~mod_precision module~mod_throw->iso_c_binding module~mod_throw->iso_fortran_env module~mod_sort mod_sort module~mod_throw->module~mod_sort module~mod_array_helpers->module~mod_precision module~mod_array_helpers->module~mod_throw module~mod_constants->module~mod_precision module~mod_constants->iso_c_binding module~mod_cpu_vendor->iso_c_binding module~mod_gradient_clipping->module~mod_precision module~mod_gradient_clipping->module~mod_settings module~mod_initialize_array->module~mod_io module~mod_initialize_array->module~mod_mpi module~mod_initialize_array->module~mod_precision module~mod_initialize_array->module~mod_throw module~mod_initialize_array->module~mod_random module~mod_parameter_file mod_parameter_file module~mod_initialize_array->module~mod_parameter_file module~mod_nan_check->module~mod_io module~mod_nan_check->module~mod_precision module~mod_nan_check->module~mod_throw ieee_arithmetic ieee_arithmetic module~mod_nan_check->ieee_arithmetic module~mod_random->module~mod_precision module~mod_random->module~mod_constants module~mod_sort->module~mod_precision module~mod_parameter_file->module~mod_io module~mod_parameter_file->module~mod_precision module~mod_parameter_file->module~mod_throw module~mod_parameter_file->module~mod_nan_check module~mod_abstract_broadcast_file mod_abstract_broadcast_file module~mod_parameter_file->module~mod_abstract_broadcast_file module~mod_abstract_broadcast_file->module~mod_io module~mod_abstract_broadcast_file->module~mod_mpi module~mod_abstract_broadcast_file->module~mod_throw module~mod_genericfile mod_genericfile module~mod_abstract_broadcast_file->module~mod_genericfile module~mod_sanitize mod_sanitize module~mod_abstract_broadcast_file->module~mod_sanitize module~mod_genericfile->module~mod_io module~mod_genericfile->module~mod_mpi module~mod_genericfile->module~mod_throw module~mod_sanitize->module~mod_throw

Used By

module~~mod_train_helpers~~UsedByGraph module~mod_train_helpers mod_train_helpers module~mod_train_4g_atomic_charges_structure_batch mod_train_4g_atomic_charges_structure_batch module~mod_train_4g_atomic_charges_structure_batch->module~mod_train_helpers module~mod_train_atomic_property_multiple_atoms mod_train_atomic_property_multiple_atoms module~mod_train_atomic_property_multiple_atoms->module~mod_train_helpers module~mod_train_energy_multiple_structures mod_train_energy_multiple_structures module~mod_train_energy_multiple_structures->module~mod_train_helpers module~mod_train_forces_multiple_structures mod_train_forces_multiple_structures module~mod_train_forces_multiple_structures->module~mod_train_helpers module~mod_train_forces_multiple_structures->module~mod_train_energy_multiple_structures module~mod_train_loop_4g_charges mod_train_loop_4g_charges module~mod_train_loop_4g_charges->module~mod_train_helpers module~mod_train_loop_4g_charges->module~mod_train_4g_atomic_charges_structure_batch module~mod_train_loop_atomic_property mod_train_loop_atomic_property module~mod_train_loop_atomic_property->module~mod_train_helpers module~mod_train_loop_atomic_property->module~mod_train_atomic_property_multiple_atoms module~mod_train_loop_short_range mod_train_loop_short_range module~mod_train_loop_short_range->module~mod_train_helpers module~mod_train_loop_short_range->module~mod_train_energy_multiple_structures module~mod_train_loop_short_range->module~mod_train_forces_multiple_structures module~mod_train_mode mod_train_mode module~mod_train_mode->module~mod_train_loop_4g_charges module~mod_train_mode->module~mod_train_loop_atomic_property module~mod_train_mode->module~mod_train_loop_short_range program~runner RuNNer program~runner->module~mod_train_mode

Procedures Summary

Name Type Description
get_loss_threshold_scale Function Match the update threshold to the normalization of the selected samples.
calc_num_updates Function Helper function for estimate_num_updates_per_optimizer to calculate `num_updates =...
is_cost_output_required Function Determines if cost information should be displayed for a given epoch. This elemental function...
cost_threshold_crossed Function Check if the cost threshold is crossed. Can be used to abort the training if the cost is below...
get_precalc_loss_norm Function Obtain the normalization factor that is applied to the reference and predicted values before...
evaluate_normalized_loss Subroutine Evaluate a local training loss and differentiate its input normalization. scale is independent...
update_optimizers_multiple_models Subroutine Update routine for simultaneous updates on parameters of multiple models. This routine iterates...
update_optimizers_single_model Subroutine Update routine for updates on parameters of a single model. This routine iterates through all...
adjust_loss_threshold_factor Subroutine Adjust the loss threshold factor. The loss threshold is the cost mutliplied by a factor. This...
warn_threshold Subroutine Add formated warning to warning handler if loss_threshold is adjusted.
set_force_update_scaling Subroutine Scale factor for force update is calculated if factor set below 0. This routine determines the...
estimate_num_updates_per_optimizer Subroutine Estimates the projected number of updates per optimizer within an epoch. Note: For...
write_optimal_epoch Subroutine Writes a formattated message about the optimal epoch.

Interface Details

interface update_optimizers


Procedure Details

function get_loss_threshold_scale

function get_loss_threshold_scale( &
    norm &
)

Match the update threshold to the normalization of the selected samples.

Arguments

  • norm : real(DP) (dim: (:)) [in]

Called By

proc~~get_loss_threshold_scale~~CalledByGraph proc~get_loss_threshold_scale mod_train_helpers::get_loss_threshold_scale proc~evaluate_charge_loss mod_train_4g_atomic_charges_structure_batch::evaluate_charge_loss proc~evaluate_charge_loss->proc~get_loss_threshold_scale proc~train_atomic_property_multiple_atoms mod_train_atomic_property_multiple_atoms::train_atomic_property_multiple_atoms proc~train_atomic_property_multiple_atoms->proc~get_loss_threshold_scale proc~train_energy_multiple_structures mod_train_energy_multiple_structures::train_energy_multiple_structures proc~train_energy_multiple_structures->proc~get_loss_threshold_scale proc~train_forces_multiple_structures mod_train_forces_multiple_structures::train_forces_multiple_structures proc~train_forces_multiple_structures->proc~get_loss_threshold_scale proc~train_forces_multiple_structures->proc~train_energy_multiple_structures proc~train_4g_atomic_charges_structure_batch mod_train_4g_atomic_charges_structure_batch::train_4g_atomic_charges_structure_batch proc~train_4g_atomic_charges_structure_batch->proc~evaluate_charge_loss proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~train_atomic_property_multiple_atoms proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~train_energy_multiple_structures proc~train_loop_short_range->proc~train_forces_multiple_structures proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~train_4g_atomic_charges_structure_batch proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range proc~train_mode->proc~train_loop_4g_charges program~runner RuNNer program~runner->proc~train_mode

function calc_num_updates

function calc_num_updates( &
    num_samples, &
    sample_multiplier, &
    sample_fraction, &
    test_fraction, &
    batchsize &
)

Helper function for estimate_num_updates_per_optimizer to calculate num_updates = int(num_samples * sample_multiplier * sample_fraction * (1 - test_fraction) * (1 / batchsize) * (1 / num_images))

Arguments

  • num_samples : integer [in]
  • sample_multiplier : integer [in]
  • sample_fraction : real(DP) [in]
  • test_fraction : real(DP) [in]
  • batchsize : integer [in]

Called By

proc~~calc_num_updates~~CalledByGraph proc~calc_num_updates mod_train_helpers::calc_num_updates proc~estimate_num_updates_per_optimizer mod_train_helpers::estimate_num_updates_per_optimizer proc~estimate_num_updates_per_optimizer->proc~calc_num_updates proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~estimate_num_updates_per_optimizer proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~estimate_num_updates_per_optimizer proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~estimate_num_updates_per_optimizer proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_4g_charges proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

function is_cost_output_required

function is_cost_output_required( &
    iepoch &
)

Determines if cost information should be displayed for a given epoch.

This elemental function evaluates whether the current training epoch (iepoch) meets the criteria for calculating the cost. Output is required if at least one of the following is true: 1. The epoch number is a multiple of global_settings%cost_frequency. 2. The epoch is the last epoch (global_settings%num_epochs). 3. The epoch is within the initial phase defined by global_settings%cost_frequency_start.

Arguments

  • iepoch : integer [in]

Called By

proc~~is_cost_output_required~~CalledByGraph proc~is_cost_output_required mod_train_helpers::is_cost_output_required proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~is_cost_output_required proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~is_cost_output_required proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~is_cost_output_required proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_4g_charges proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

function cost_threshold_crossed

function cost_threshold_crossed( &
    cost, &
    epoch &
)

Check if the cost threshold is crossed.

Can be used to abort the training if the cost is below the lower cost threshold or above the upper cost threshold. The cost is checked against the set threshold only after the lower and upper cost threshold epochs have been reached.

Arguments

  • cost : real(DP) (dim: (global_settings%num_committee_members)) [in]– Cost of the current epoch, e.g. the RMSE.
  • epoch : integer [in]– Current epoch of the training.

Called By

proc~~cost_threshold_crossed~~CalledByGraph proc~cost_threshold_crossed mod_train_helpers::cost_threshold_crossed proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~cost_threshold_crossed proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~cost_threshold_crossed proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~cost_threshold_crossed proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_4g_charges proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

function get_precalc_loss_norm

function get_precalc_loss_norm( &
    name, &
    num_atoms_sample &
)

Obtain the normalization factor that is applied to the reference and predicted values before loss calculation for arbitrary properties.

Arguments

  • name : character [in]
  • num_atoms_sample : integer [in]

Called By

proc~~get_precalc_loss_norm~~CalledByGraph proc~get_precalc_loss_norm mod_train_helpers::get_precalc_loss_norm proc~train_4g_atomic_charges_structure_batch mod_train_4g_atomic_charges_structure_batch::train_4g_atomic_charges_structure_batch proc~train_4g_atomic_charges_structure_batch->proc~get_precalc_loss_norm proc~train_atomic_property_multiple_atoms mod_train_atomic_property_multiple_atoms::train_atomic_property_multiple_atoms proc~train_atomic_property_multiple_atoms->proc~get_precalc_loss_norm proc~train_energy_multiple_structures mod_train_energy_multiple_structures::train_energy_multiple_structures proc~train_energy_multiple_structures->proc~get_precalc_loss_norm proc~train_forces_multiple_structures mod_train_forces_multiple_structures::train_forces_multiple_structures proc~train_forces_multiple_structures->proc~get_precalc_loss_norm proc~train_forces_multiple_structures->proc~train_energy_multiple_structures proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~train_4g_atomic_charges_structure_batch proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~train_atomic_property_multiple_atoms proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~train_energy_multiple_structures proc~train_loop_short_range->proc~train_forces_multiple_structures proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_4g_charges proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

subroutine evaluate_normalized_loss

subroutine evaluate_normalized_loss( &
    loss_function, &
    prediction, &
    reference, &
    scale, &
    loss, &
    gradients &
)

Evaluate a local training loss and differentiate its input normalization. scale is independent of the model parameters; gradients are with respect to the unscaled prediction. Training losses must use collect = .false.

Arguments

  • loss_function : class(AbstractLossFunction) [in]
  • prediction : real(DP) (dim: (:)) [in]
  • reference : real(DP) (dim: (:)) [in]
  • scale : real(DP) (dim: (:)) [in]
  • loss : real(DP) [out]
  • gradients : real(DP) (dim: (size(prediction))) [out]

Called By

proc~~evaluate_normalized_loss~~CalledByGraph proc~evaluate_normalized_loss mod_train_helpers::evaluate_normalized_loss proc~evaluate_atomic_property_loss mod_train_atomic_property_multiple_atoms::evaluate_atomic_property_loss proc~evaluate_atomic_property_loss->proc~evaluate_normalized_loss proc~evaluate_charge_loss mod_train_4g_atomic_charges_structure_batch::evaluate_charge_loss proc~evaluate_charge_loss->proc~evaluate_normalized_loss proc~evaluate_energy_loss mod_train_energy_multiple_structures::evaluate_energy_loss proc~evaluate_energy_loss->proc~evaluate_normalized_loss proc~evaluate_force_loss mod_train_forces_multiple_structures::evaluate_force_loss proc~evaluate_force_loss->proc~evaluate_normalized_loss proc~train_4g_atomic_charges_structure_batch mod_train_4g_atomic_charges_structure_batch::train_4g_atomic_charges_structure_batch proc~train_4g_atomic_charges_structure_batch->proc~evaluate_charge_loss proc~train_atomic_property_multiple_atoms mod_train_atomic_property_multiple_atoms::train_atomic_property_multiple_atoms proc~train_atomic_property_multiple_atoms->proc~evaluate_atomic_property_loss proc~train_energy_multiple_structures mod_train_energy_multiple_structures::train_energy_multiple_structures proc~train_energy_multiple_structures->proc~evaluate_energy_loss proc~train_forces_multiple_structures mod_train_forces_multiple_structures::train_forces_multiple_structures proc~train_forces_multiple_structures->proc~evaluate_force_loss proc~train_forces_multiple_structures->proc~train_energy_multiple_structures proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~train_4g_atomic_charges_structure_batch proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~train_atomic_property_multiple_atoms proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~train_energy_multiple_structures proc~train_loop_short_range->proc~train_forces_multiple_structures proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_4g_charges proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

subroutine update_optimizers_multiple_models

subroutine update_optimizers_multiple_models( &
    models, &
    optimizers, &
    loss, &
    loss_function, &
    atomic_numbers, &
    mpi_update &
)

Update routine for simultaneous updates on parameters of multiple models.

This routine iterates through all provided optimizers. For each optimizer, it aggregates the parameters and their corresponding gradients from all models that are associated with that specific optimizer and share a loss function type.

The batch loss and its parameter gradients are passed without additional normalization. Finally, the optimizer's step method is called to update the parameters, and the updated parameters are distributed back into the respective models. The models and their parameter gradients are then reset.

Arguments

  • models : class(ModelPtr) (dim: (:)) [inout]– Array of models. The parameters of these models are updated. The loss gradient has to be already backward passed through the models. Parameter gradients are stored on the models.
  • optimizers : type(OptimizerPtr) (dim: (:)) [inout]– Optimizers potentially used to update the models. Each optimizer performs maximum one update during this routine.
  • loss : real(DP) [in]– Calculated total loss of the batch.
  • loss_function : type(LossFunctionPtr) [in]– Loss function that was used to calculate the loss and perform the backward pass. Optimizers which use a different loss function are not updated.
  • atomic_numbers : integer (dim: (:)) [in]– Atomic numbers of active atoms, used to select participating optimizers.
  • mpi_update : integer [in]– Signals if this process should do an update. A value of 0 signals no update, a value of 1 an update. There is e.g. no update if the loss is below the loss threshold.

Called By

proc~~update_optimizers_multiple_models~~CalledByGraph proc~update_optimizers_multiple_models mod_train_helpers::update_optimizers_multiple_models interface~update_optimizers mod_train_helpers::update_optimizers interface~update_optimizers->proc~update_optimizers_multiple_models proc~train_4g_atomic_charges_structure_batch mod_train_4g_atomic_charges_structure_batch::train_4g_atomic_charges_structure_batch proc~train_4g_atomic_charges_structure_batch->interface~update_optimizers proc~train_atomic_property_multiple_atoms mod_train_atomic_property_multiple_atoms::train_atomic_property_multiple_atoms proc~train_atomic_property_multiple_atoms->interface~update_optimizers proc~train_energy_multiple_structures mod_train_energy_multiple_structures::train_energy_multiple_structures proc~train_energy_multiple_structures->interface~update_optimizers proc~train_forces_multiple_structures mod_train_forces_multiple_structures::train_forces_multiple_structures proc~train_forces_multiple_structures->interface~update_optimizers proc~train_forces_multiple_structures->proc~train_energy_multiple_structures proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~train_4g_atomic_charges_structure_batch proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~train_atomic_property_multiple_atoms proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~train_energy_multiple_structures proc~train_loop_short_range->proc~train_forces_multiple_structures proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_4g_charges proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

subroutine update_optimizers_single_model

subroutine update_optimizers_single_model( &
    model, &
    optimizers, &
    loss, &
    loss_function, &
    atomic_numbers, &
    mpi_update &
)

Update routine for updates on parameters of a single model.

This routine iterates through all provided optimizers. For each optimizer, it aggregates the parameters and their corresponding gradients from the model if the model is associated with the optimizer and they share a loss function type.

The batch loss and its parameter gradients are passed without additional normalization. Finally, the optimizer's step method is called to update the parameters, and the updated parameters are distributed back into the model. The model and its parameter gradients are then reset.

Arguments

  • model : class(AbstractPropertyModel) [inout]– Model for which the parameters are updated. The loss gradient has to be already backward passed through the model. Parameter gradients are stored on the model.
  • optimizers : type(OptimizerPtr) (dim: (:)) [inout]– Optimizers potentially used to update the model. Each optimizer performs maximum one update during this routine.
  • loss : real(DP) [in]– Calculated total loss of the batch.
  • loss_function : type(LossFunctionPtr) [in]– Loss function that was used to calculate the loss and perform the backward pass. Optimizers which use a different loss function are not updated.
  • atomic_numbers : integer (dim: (:)) [in]– Atomic numbers of active atoms, used to select participating optimizers.
  • mpi_update : integer [in]– Signals if this process should do an update. A value of 0 signals no update, a value of 1 an update. There is e.g. no update if the loss is below the loss threshold.

Called By

proc~~update_optimizers_single_model~~CalledByGraph proc~update_optimizers_single_model mod_train_helpers::update_optimizers_single_model interface~update_optimizers mod_train_helpers::update_optimizers interface~update_optimizers->proc~update_optimizers_single_model proc~train_4g_atomic_charges_structure_batch mod_train_4g_atomic_charges_structure_batch::train_4g_atomic_charges_structure_batch proc~train_4g_atomic_charges_structure_batch->interface~update_optimizers proc~train_atomic_property_multiple_atoms mod_train_atomic_property_multiple_atoms::train_atomic_property_multiple_atoms proc~train_atomic_property_multiple_atoms->interface~update_optimizers proc~train_energy_multiple_structures mod_train_energy_multiple_structures::train_energy_multiple_structures proc~train_energy_multiple_structures->interface~update_optimizers proc~train_forces_multiple_structures mod_train_forces_multiple_structures::train_forces_multiple_structures proc~train_forces_multiple_structures->interface~update_optimizers proc~train_forces_multiple_structures->proc~train_energy_multiple_structures proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~train_4g_atomic_charges_structure_batch proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~train_atomic_property_multiple_atoms proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~train_energy_multiple_structures proc~train_loop_short_range->proc~train_forces_multiple_structures proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_4g_charges proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

subroutine adjust_loss_threshold_factor

subroutine adjust_loss_threshold_factor( &
    num_updates, &
    initial_threshold_factor, &
    threshold_factor, &
    lallow_reset, &
    property_label &
)

Adjust the loss threshold factor.

The loss threshold is the cost mutliplied by a factor. This factor is adjusted here. In case no structures were updated during the last epoch, the factor is decreased to make the loss threshold less restrictive and allow for more updates.

If then an epoch performed updates again, the factor is increased slowly up to the starting value. author: Alea Tokita and Moritz Schaefer

Arguments

  • num_updates : integer [in]– Number of updates in the last epoch.
  • initial_threshold_factor : real(DP) [in]– Initial loss threshold factor as defined by the user in the input.nn file.
  • threshold_factor : real(DP) [inout]– Current loss threshold factor as modified by this routine.
  • lallow_reset : logical [in]– If set to false the loss threshold factor can not increase again.
  • property_label : character [in]– Name of property of which the threshold is checked.

Called By

proc~~adjust_loss_threshold_factor~~CalledByGraph proc~adjust_loss_threshold_factor mod_train_helpers::adjust_loss_threshold_factor proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~adjust_loss_threshold_factor proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~adjust_loss_threshold_factor proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~adjust_loss_threshold_factor proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_4g_charges proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

subroutine warn_threshold

subroutine warn_threshold( &
    threshold, &
    property_label &
)

Add formated warning to warning handler if loss_threshold is adjusted.

Arguments

  • threshold : real(DP) [in]– New loss threshold factor after change.
  • property_label : character [in]– Name of property of which the threshold is adjusted.

Called By

proc~~warn_threshold~~CalledByGraph proc~warn_threshold mod_train_helpers::warn_threshold proc~adjust_loss_threshold_factor mod_train_helpers::adjust_loss_threshold_factor proc~adjust_loss_threshold_factor->proc~warn_threshold proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~adjust_loss_threshold_factor proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~adjust_loss_threshold_factor proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~adjust_loss_threshold_factor proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_4g_charges proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

subroutine set_force_update_scaling

subroutine set_force_update_scaling( &
    force_update_scaling_in, &
    batchsize_forces, &
    batchsize_structures, &
    energy_fraction, &
    force_fraction, &
    num_atoms_per_element, &
    force_update_scaling &
)

Scale factor for force update is calculated if factor set below 0.

This routine determines the force update scaling factor for each element. If the input scaling factor for a specific element is set to a negative value, the routine calculates an element-specific scaling factor based on batchsizes of energies and forces, the energy and force fractions, and the number of atoms of that element. The factor is calculated in a way to make sure that the total importance of the force updates of each element over the structure batch is equal to the total importance of the energy updates in the structure batch.

If the force update scaling factor is positive, it is used directly. @todo Element decoupeled Kalman Filter routines have more advanced method, could be used here author: Alea Tokita, Alexander Knoll

Arguments

  • force_update_scaling_in : real(DP) (dim: (MAX_ELEM_NUM)) [in]– Array of original force update scaling factors for each element.
  • batchsize_forces : integer (dim: (MAX_ELEM_NUM)) [in]– Force batchsize for each element.
  • batchsize_structures : integer [in]– Structure batchsize.
  • energy_fraction : real(DP) [in]– Fraction of energies of the structurebatch used for training in each epoch.
  • force_fraction : real(DP) (dim: (MAX_ELEM_NUM)) [in]– Fraction of forces of the structurebatch used for training in each epoch.
  • num_atoms_per_element : integer (dim: (MAX_ELEM_NUM)) [in]– Number of atoms per element in the structurebatch.
  • force_update_scaling : real(DP) (dim: (MAX_ELEM_NUM)) [out]– Actual used force update scaling factor calculated in this routine.

Called By

proc~~set_force_update_scaling~~CalledByGraph proc~set_force_update_scaling mod_train_helpers::set_force_update_scaling proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~set_force_update_scaling proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

subroutine estimate_num_updates_per_optimizer

subroutine estimate_num_updates_per_optimizer( &
    optimizers, &
    fit_target, &
    test_fraction, &
    tot_num_structures, &
    use_energy, &
    use_forces, &
    use_force_vectors, &
    lrepeated_energy_update, &
    energy_fraction, &
    force_fraction, &
    batchsize_structures, &
    batchsize_forces, &
    atomic_nn_opt_ids, &
    atomic_numbers, &
    num_atoms_element, &
    atomic_property_fraction, &
    batchsize_elements, &
    num_updates_energy, &
    num_updates_forces, &
    num_updates_property &
)

Estimates the projected number of updates per optimizer within an epoch.

Note: For "energy_and_force" fits, the routine doesn't account for differing update rates in case of datasets with structures which don't include all elements. Author: Redouan El Haouari

Arguments

  • optimizers : type(OptimizerPtr) (dim: (:)) [in]– List of `optimizer`s for which the number of projected updates is estimated.
  • fit_target : character [in]– Target can be either a `"energy_and_force"` fit or an `"atomic_property"` fit.
  • test_fraction : real(DP) [in]– Fraction of the structure contained in `input.data` which are used as test set.
  • tot_num_structures : integer [in]– Total number of structures in the dataset.
  • use_energy : logical [in]– Sets, whether energy updates are performed.
  • use_forces : logical [in]– Sets, whether force updates are performed.
  • use_force_vectors : logical [in]– Sets, whetehr force updates are performed with the norm of the force vectors. If `.false.`, force components are used (which is the default anyway).
  • lrepeated_energy_update : logical [in]– Sets, whether a force update is followed by an energy updates. Not affected by `use_energy`.
  • energy_fraction : real(DP) [in]– Fraction of the structure samples, excluding those in the test set, used for energy training.
  • force_fraction : real(DP) (dim: (MAX_ELEM_NUM)) [in]– Fraction of the force samples, excluding those in the test set, used for force training.
  • batchsize_structures : integer [in]– Size of the structure batch in each energy update.
  • batchsize_forces : integer (dim: (MAX_ELEM_NUM)) [in]– Size of the force batch in each force update.
  • atomic_nn_opt_ids : integer (dim: (:)) [in]– List of all atomic neural networks present in the `HDNN` model.
  • atomic_numbers : integer (dim: (:)) [in]– List of all atomic numbers present in the `HDNN` model.
  • num_atoms_element : integer (dim: (MAX_ELEM_NUM)) [in]– Number of atoms per element in the dataset.
  • atomic_property_fraction : real(DP) (dim: (MAX_ELEM_NUM)) [in]– Fraction of the atomic property samples, excluding those in the test set, used for atomic property training.
  • batchsize_elements : integer (dim: (MAX_ELEM_NUM)) [in]– Size of the atomic property batch in each atomic property update.
  • num_updates_energy : integer (dim: (:)) [out]– Projected number of energy updates for this epoch. All entries in the array are identical.
  • num_updates_forces : integer (dim: (:)) [out]– Projected number of force updates for this epoch. All entries in the array are identical.
  • num_updates_property : integer (dim: (:)) [out]– Projected number of atomic property updates per optimizer for this epoch.

Called By

proc~~estimate_num_updates_per_optimizer~~CalledByGraph proc~estimate_num_updates_per_optimizer mod_train_helpers::estimate_num_updates_per_optimizer proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~estimate_num_updates_per_optimizer proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~estimate_num_updates_per_optimizer proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~estimate_num_updates_per_optimizer proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_4g_charges proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode

subroutine write_optimal_epoch

subroutine write_optimal_epoch( &
    optimal_epoch, &
    opt_epoch_property, &
    ltest &
)

Writes a formattated message about the optimal epoch.

Arguments

  • optimal_epoch : integer [in]– The optimal epoch, which is determined as the epoch with lowest cost with respect to the train/test set of a trained property.
  • opt_epoch_property : character [in]– Property that is used to determine the optimal epoch.
  • ltest : logical [in]– Flag whether train or test set is used to determine the optimal epoch.

Called By

proc~~write_optimal_epoch~~CalledByGraph proc~write_optimal_epoch mod_train_helpers::write_optimal_epoch proc~train_loop_4g_charges mod_train_loop_4g_charges::train_loop_4g_charges proc~train_loop_4g_charges->proc~write_optimal_epoch proc~train_loop_atomic_property mod_train_loop_atomic_property::train_loop_atomic_property proc~train_loop_atomic_property->proc~write_optimal_epoch proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~write_optimal_epoch proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_4g_charges proc~train_mode->proc~train_loop_atomic_property proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode