mod_create_batches¶
Routines to create batches author: Alexander Knoll
Dependencies¶
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
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