mod_cost_epoch¶
Routines helpful for calculating and reporting cost function values during training. author: Alexander Knoll
Dependencies¶
Module Variables¶
-
TRAIN: integer– Parameter to specify the training dataset. -
TEST: integer– Parameter to specify the test dataset.
Procedures Summary¶
| Name | Type | Description |
|---|---|---|
get_cost_for_checking_opt_epoch |
Function | Extracts the cost used to check for the optimal epoch. This can be from either the training or... |
separate_structure_and_atom_properties |
Subroutine | Determines the indices and sizes of all properties to be evaluated. This routine inspects the... |
calculate_cost_all_properties_epoch |
Subroutine | Calculates the cost for all specified properties, cost functions, and committee members. This... |
sum_up_contributions |
Subroutine | |
print_epoch_line_start |
Subroutine | Prints the header for a line of cost values. This includes the cost function name, epoch, and... |
print_cost_values_epoch |
Subroutine | Prints the calculated training and test cost values for an epoch to standard output. |
print_num_updates_to_stdout |
Subroutine | Prints the number of weight updates for all committee members and properties to STDOUT. The... |
print_epoch_timing_to_stdout |
Subroutine | Prints the walltime elapsed since the last call to this routine. This is intended to time the... |
Procedure Details¶
function get_cost_for_checking_opt_epoch¶
function get_cost_for_checking_opt_epoch( &
optimal_epoch_cost_function_index, &
optimal_epoch_property_index, &
loptimal_epoch_train, &
train_cost, &
test_cost &
)
Extracts the cost used to check for the optimal epoch.
This can be from either the training or test set for a specific property and cost function.
Arguments
-
optimal_epoch_cost_function_index: integer [in]– The index of the cost function used for determining the optimal epoch. -
optimal_epoch_property_index: integer [in]– The index of the property used for determining the optimal epoch. -
loptimal_epoch_train: logical [in]– If true, use the training cost; otherwise, use the test cost. -
train_cost: real(DP) (dim: (:,:,:)) [in]– The full array of training costs. -
test_cost: real(DP) (dim: (:,:,:)) [in]– The full array of test costs.
Called By
subroutine separate_structure_and_atom_properties¶
subroutine separate_structure_and_atom_properties( &
num_properties, &
committee_size, &
tag_to_sum, &
property_type, &
results_pred, &
results_ref, &
max_nrows_structure_properties, &
max_nrows_atom_properties, &
nrows_props &
)
Determines the indices and sizes of all properties to be evaluated.
This routine inspects the property names and types to figure out their
indices within the DatasetStorage objects and determines the maximum
number of rows for structure- and atom-based properties, respectively.
Arguments
-
num_properties: integer [in]– The total number of properties to process. -
committee_size: integer [in]– The number of committee members. -
tag_to_sum: integer (dim: (num_properties)) [in]– For each property, the tag that should be looked up in the given reference, prediction, and fixed results classes. -
property_type: character (dim: (num_properties)) [in]– The type of each property, either "structure" or "atom". -
results_pred: type(DatasetStorage) (dim: (:)) [inout]– The storage for predicted results for each committee member. -
results_ref: type(DatasetStorage) [in]– The storage for reference results. -
max_nrows_structure_properties: integer [out]– On exit, the maximum number of rows among all structure properties. -
max_nrows_atom_properties: integer [out]– On exit, the maximum number of rows among all atom properties. -
nrows_props: integer (dim: (num_properties)) [out]– On exit, the number of rows for each individual property.
Called By
subroutine calculate_cost_all_properties_epoch¶
subroutine calculate_cost_all_properties_epoch( &
num_properties, &
committee_size, &
results_pred, &
results_ref, &
tag_to_sum, &
lhas_test_set, &
train_atom_id_on_process_across_chunks_pred, &
test_atom_id_on_process_across_chunks_pred, &
train_atom_id_on_process_across_chunks_ref, &
test_atom_id_on_process_across_chunks_ref, &
train_struc_id_on_process_across_chunks_pred, &
test_struc_id_on_process_across_chunks_pred, &
train_struc_id_on_process_across_chunks_ref, &
test_struc_id_on_process_across_chunks_ref, &
property_type, &
lproperty_per_atom, &
use_comm_ref, &
ladd_precomputed_contributions, &
max_nrows_structure_properties, &
max_nrows_atom_properties, &
nrows_props, &
cost_functions, &
train_cost, &
test_cost, &
train_cost_element, &
test_cost_element, &
lcost_element, &
results_precomputed &
)
Calculates the cost for all specified properties, cost functions, and committee members.
This routine orchestrates the main calculation for an epoch. It gathers all necessary predicted and reference data into flat arrays and then invokes the specified cost functions to compute the training and test errors.
Arguments
-
num_properties: integer [in]– The total number of properties to process. -
committee_size: integer [in]– The number of committee members. -
results_pred: type(DatasetStorage) (dim: (committee_size)) [in]– Storage for predicted results for each committee member. -
results_ref: type(DatasetStorage) [in]– Storage for reference results. -
tag_to_sum: integer (dim: (num_properties)) [in]– The tags identifying the columns that are summed up for each property. The same tags are used for all types of properties. -
lhas_test_set: logical [in]– True if a test set is present. -
train_atom_id_on_process_across_chunks_pred: integer (dim: (:)) [in]– Global indices of training atoms for predictions on this process. -
test_atom_id_on_process_across_chunks_pred: integer (dim: (:)) [in]– Global indices of test atoms for predictions on this process. -
train_atom_id_on_process_across_chunks_ref: integer (dim: (:)) [in]– Global indices of training atoms for reference on this process. These differ from the predicted atom indices, because we only store the reference values on the root MPI process. -
test_atom_id_on_process_across_chunks_ref: integer (dim: (:)) [in]– Global indices of test atoms for reference on this process. -
train_struc_id_on_process_across_chunks_pred: integer (dim: (:)) [in]– Global indices of training structures for predictions on this process. -
test_struc_id_on_process_across_chunks_pred: integer (dim: (:)) [in]– Global indices of test structures for predictions on this process. -
train_struc_id_on_process_across_chunks_ref: integer (dim: (:)) [in]– Global indices of training structures for reference on this process. -
test_struc_id_on_process_across_chunks_ref: integer (dim: (:)) [in]– Global indices of test structures for reference on this process. -
property_type: character (dim: (num_properties)) [in]– The type of each property, either "structure" or "atom". -
lproperty_per_atom: logical (dim: (num_properties)) [in]– If true for a property, its values are divided by the number of atoms. -
use_comm_ref: logical (dim: (num_properties)) [in]– If true, committee-specific reference values will be used. -
ladd_precomputed_contributions: logical [in]– If true, add values from other tagged properties to the prediction. -
max_nrows_structure_properties: integer [in]– The maximum number of rows among all structure properties. -
max_nrows_atom_properties: integer [in]– The maximum number of rows among all atom properties. -
nrows_props: integer (dim: (num_properties)) [in]– The number of rows for each individual property. -
cost_functions: type(LossFunctionPtr) (dim: (:)) [inout]– Array of cost function objects to be evaluated. -
train_cost: real(DP) (dim: (size(cost_functions),committee_size,num_properties)) [out]– On exit, the calculated training cost for each cost function, committee, and property. -
test_cost: real(DP) (dim: (size(cost_functions),committee_size,num_properties)) [out]– On exit, the calculated test cost for each cost function, committee, and property. -
train_cost_element: real(DP) (dim: (size(cost_functions),committee_size,num_properties,MAX_ELEM_NUM)) [out]– On exit, the calculated training cost for each cost function, committee, and property element resolved. -
test_cost_element: real(DP) (dim: (size(cost_functions),committee_size,num_properties,MAX_ELEM_NUM)) [out]– On exit, the calculated test cost for each cost function, committee, and property element resolved. -
lcost_element: logical [in]– Whether to calculate element resolved cost. -
results_precomputed: type(DatasetStorage) (dim: (committee_size)) [in]– Container storing values of precomputed properties.
Called By
subroutine sum_up_contributions¶
subroutine sum_up_contributions( &
contrib_indices, &
nrows, &
sample_indices_on_process, &
prop_list, &
luse_comm_name, &
committee_idx, &
sum &
)
Arguments
-
contrib_indices: integer (dim: (:)) [in] -
nrows: integer [in] -
sample_indices_on_process: integer (dim: (:)) [in] -
prop_list: type(PropertyListReal) [in] -
luse_comm_name: logical [in] -
committee_idx: integer [in] -
sum: real(DP) (dim: (nrows,size(sample_indices_on_process))) [inout]
Called By
subroutine print_epoch_line_start¶
subroutine print_epoch_line_start( &
cost_function, &
epoch, &
committee_idx &
)
Prints the header for a line of cost values.
This includes the cost function name, epoch, and committee index.
Example: "RMSE [epoch] [comm_idx]"
Arguments
-
cost_function: type(LossFunctionPtr) [in]– The cost function object, used to retrieve the name. -
epoch: integer [in]– The current epoch index. -
committee_idx: integer [in]– The current committee member index.
Called By
subroutine print_cost_values_epoch¶
subroutine print_cost_values_epoch( &
cost_functions, &
train_cost, &
test_cost, &
property_unit_conv, &
epoch &
)
Prints the calculated training and test cost values for an epoch to standard output.
Arguments
-
cost_functions: type(LossFunctionPtr) (dim: (:)) [in]– Array of cost function objects, used for printing headers. -
train_cost: real(DP) (dim: (:,:,:)) [in]– The calculated training costs (cost_function, committee, property). -
test_cost: real(DP) (dim: (:,:,:)) [in]– The calculated test costs (cost_function, committee, property). -
property_unit_conv: real(DP) (dim: (:)) [in]– Unit conversion factors to apply to each property's cost before printing. -
epoch: integer [in]– The current epoch index.
Called By
subroutine print_num_updates_to_stdout¶
subroutine print_num_updates_to_stdout( &
committee_size, &
num_properties, &
num_updates, &
epoch &
)
Prints the number of weight updates for all committee members and properties to STDOUT.
The format is:
UPDATES [epoch] [committee_index] [No. Updates Prop 1] [No. Updates Prop 2] ...
Arguments
-
committee_size: integer [in]– The number of committee members. -
num_properties: integer [in]– The number of properties. -
num_updates: integer (dim: (committee_size,num_properties)) [in]– The number of updates for each committee and property. -
epoch: integer [in]– The current epoch index.
Called By
subroutine print_epoch_timing_to_stdout¶
subroutine print_epoch_timing_to_stdout( &
epoch &
)
Prints the walltime elapsed since the last call to this routine. This is intended to time the duration of one epoch.
The format is:
TIMING [epoch] [wall_time] min
Arguments
-
epoch: integer [in]– The current epoch index.
Called By