Skip to content

mod_create_batches

Lines: 157 | Visibility: private

Routines to create batches author: Alexander Knoll

Dependencies

Uses

module~~mod_create_batches~~UsesGraph module~mod_create_batches mod_create_batches module~mod_databatcher mod_databatcher module~mod_create_batches->module~mod_databatcher module~mod_mpi mod_mpi module~mod_create_batches->module~mod_mpi module~mod_periodic_table mod_periodic_table module~mod_create_batches->module~mod_periodic_table module~mod_precision mod_precision module~mod_create_batches->module~mod_precision module~mod_databatcher->module~mod_mpi module~mod_databatcher->module~mod_precision module~mod_array_helpers mod_array_helpers module~mod_databatcher->module~mod_array_helpers module~mod_random mod_random module~mod_databatcher->module~mod_random module~mod_throw mod_throw module~mod_databatcher->module~mod_throw module~mod_mpi->module~mod_precision mpi_f08 mpi_f08 module~mod_mpi->mpi_f08 module~mod_periodic_table->module~mod_precision module~mod_periodic_table->module~mod_array_helpers module~mod_constants mod_constants module~mod_periodic_table->module~mod_constants module~mod_io mod_io module~mod_periodic_table->module~mod_io module~mod_periodic_table->module~mod_throw iso_c_binding iso_c_binding module~mod_precision->iso_c_binding iso_fortran_env iso_fortran_env module~mod_precision->iso_fortran_env 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_io->module~mod_precision module~mod_io->iso_fortran_env module~mod_optional_args mod_optional_args module~mod_io->module~mod_optional_args module~mod_random->module~mod_precision module~mod_random->module~mod_constants 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_throw->module~mod_io module~mod_sort mod_sort module~mod_throw->module~mod_sort module~mod_sort->module~mod_precision

Used By

module~~mod_create_batches~~UsedByGraph module~mod_create_batches mod_create_batches 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_create_batches module~mod_train_atomic_property_multiple_atoms mod_train_atomic_property_multiple_atoms module~mod_train_atomic_property_multiple_atoms->module~mod_create_batches module~mod_train_loop_short_range mod_train_loop_short_range module~mod_train_loop_short_range->module~mod_create_batches module~mod_train_loop_4g_charges mod_train_loop_4g_charges 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_atomic_property_multiple_atoms module~mod_train_mode mod_train_mode module~mod_train_mode->module~mod_train_loop_short_range module~mod_train_mode->module~mod_train_loop_4g_charges module~mod_train_mode->module~mod_train_loop_atomic_property program~runner RuNNer program~runner->module~mod_train_mode

Procedures Summary

Name Type Description
create_atom_batches Subroutine Create batches of atoms based on the chosen user settings. This is a wrapper around the generic...
create_force_batches Subroutine

Procedure Details

subroutine create_atom_batches

subroutine create_atom_batches( &
    data_batcher, &
    num_samples, &
    atomic_numbers, &
    batchsize_elements, &
    element_fractions, &
    apply_fraction_by_element, &
    batch_by_element, &
    shuffle, &
    batchsize_elements_num_atoms_in_structure_batch, &
    num_batches, &
    num_atoms_per_batch, &
    indices_per_batch &
)

Create batches of atoms based on the chosen user settings.

This is a wrapper around the generic data_batcher%batch routine that creates batches for training of atomic properties like charges, energies, or forces/force vectors. It contains the logic necessary to pass the right indices and settings to the data_batcher and is reusable throughout most training scenarios. In the context of this subroutine we need to know two key terms: - sample: samples are one piece of training information, be it one atomic charge or force component. This routine only needs to know how many samples (num_samples) are supposed to be batched. - group: in dataloader terminology each sample belongs to a group. In most cases, this will be the atomic number of the atom. We differentiate the group of the sample, which is used to decide which samples can put put together in one batch, and the fraction_group that determines how a subset of samples is drawn from the list of all samples. The keywords batch_by_element and apply_fraction_by_element control whether we consider the element of a sample for the batching and/or fractioning decisions.

Arguments

  • data_batcher : class(DataBatcher) [inout]– Initialized dataloader instace. This is mostly used to keep track of the random number generator states that are used for shuffling/fractioning.
  • num_samples : integer [in]– How many samples will be put in batches. Samples can be anything from atomic charges to force components.
  • atomic_numbers : integer (dim: (num_samples)) [in]– For each sample, the atomic number of its atom.
  • batchsize_elements : integer (dim: (MAX_ELEM_NUM)) [in]– How many samples should be put into one batch.
  • element_fractions : real(DP) (dim: (MAX_ELEM_NUM)) [in]– How many samples are to be selected for each element.
  • apply_fraction_by_element : logical [in]– If True, we take the `atomic_number` into account for the application of the given `element_fractions`. If False, all samples are considered to be part of group `1` and selected indiscriminantly.
  • batch_by_element : logical [in]– If True, we take the `atomic_number` of each sample into account for the batching decisions. In that case, only element-"pure" batches are created. Fractions and batchsizes are independent of this.
  • shuffle : logical [in]– Whether to shuffle batches.
  • batchsize_elements_num_atoms_in_structure_batch : logical [in]– If True, all `batchsize_elements` are disregarded. Instead, we create one single batch containing all atoms in the structure. `batch_by_element` is still applied and controls whether there is one batch with all atoms or one batch per element with all atoms of that element.
  • num_batches : integer [out]– How many batches there are.
  • num_atoms_per_batch : integer (dim: (:)) [out]– How many samples are contained in each batch.
  • indices_per_batch : integer (dim: (:,:)) [out]– The indices of the samples in each batch. The indices are a continuous list ranging from 1 to `num_samples`. They are subject to `shuffle`ing.

Called By

proc~~create_atom_batches~~CalledByGraph proc~create_atom_batches mod_create_batches::create_atom_batches proc~create_force_batches mod_create_batches::create_force_batches proc~create_force_batches->proc~create_atom_batches 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~create_atom_batches proc~train_atomic_property_multiple_atoms mod_train_atomic_property_multiple_atoms::train_atomic_property_multiple_atoms proc~train_atomic_property_multiple_atoms->proc~create_atom_batches 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~create_force_batches 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 create_force_batches

subroutine create_force_batches( &
    data_batcher, &
    nstrucs, &
    tot_nat, &
    nat_per_struc, &
    id_on_process_atoms, &
    id_in_struc_atoms, &
    atomic_numbers, &
    map_atom_to_struc, &
    batchsize, &
    element_fractions, &
    use_force_vectors, &
    apply_fraction_by_element, &
    batch_by_element, &
    shuffle, &
    batchsize_elements_num_atoms_in_structure_batch, &
    num_force_batches, &
    num_samples_in_batch, &
    batch_mapping, &
    id_on_process_target_atoms, &
    id_in_struc_target_atoms, &
    indices_xyz_target, &
    atomic_numbers_target_atoms, &
    map_target_atom_to_structure_idx, &
    nat_per_struc_target_atoms &
)

Arguments

  • data_batcher : class(DataBatcher) [inout]– An initialized dataloader object that is used for shuffeling and batching. The internal state of the attached random number generators changes.
  • nstrucs : integer [in]– The number of structures from which forces are selected.
  • tot_nat : integer [in]– The total number of atoms in all structures. Should be the sum of `nat_per_struc`.
  • nat_per_struc : integer (dim: (nstrucs)) [in]– The number of atoms of each structure.
  • id_on_process_atoms : integer (dim: (tot_nat)) [in]– The id_on_process of each atom in the structures.
  • id_in_struc_atoms : integer (dim: (tot_nat)) [in]
  • atomic_numbers : integer (dim: (tot_nat)) [in]– The atomic number of each atom in the structures.
  • map_atom_to_struc : integer (dim: (tot_nat)) [in]
  • batchsize : integer (dim: (MAX_ELEM_NUM)) [in]– For each element, the desired number of samples of that element that are batched together.
  • element_fractions : real(DP) (dim: (MAX_ELEM_NUM)) [in]– The percentage of samples of each element that are selected and included in the batches.
  • use_force_vectors : logical [in]– Whether to select the full force vector of each atom or choose from a list of all force components.
  • apply_fraction_by_element : logical [in]– If True, the given `element_fractions` are applied on a per-element basis. Otherwise, all samples are grouped together and the fraction is applied afterwards to all of them.
  • batch_by_element : logical [in]– If True, only atoms of the same element are batched together.
  • shuffle : logical [in]– Whether to shuffle samples within batches and shuffle batches.
  • batchsize_elements_num_atoms_in_structure_batch : logical [in]– This flag overrides the given `batchsize` and instead sets it the number of atoms per element in the given list of `atomic_numbers`.
  • num_force_batches : integer [out]– How many force batches there are.
  • num_samples_in_batch : integer (dim: (:)) [out]– How many force components are included in each batch.
  • batch_mapping : integer (dim: (:,:)) [out]
  • id_on_process_target_atoms : integer (dim: (:)) [out]
  • id_in_struc_target_atoms : integer (dim: (:)) [out]
  • indices_xyz_target : integer (dim: (:)) [out]
  • atomic_numbers_target_atoms : integer (dim: (:)) [out]
  • map_target_atom_to_structure_idx : integer (dim: (:)) [out]
  • nat_per_struc_target_atoms : integer (dim: (:)) [out]

Called By

proc~~create_force_batches~~CalledByGraph proc~create_force_batches mod_create_batches::create_force_batches proc~train_loop_short_range mod_train_loop_short_range::train_loop_short_range proc~train_loop_short_range->proc~create_force_batches proc~train_mode mod_train_mode::train_mode proc~train_mode->proc~train_loop_short_range program~runner RuNNer program~runner->proc~train_mode