athena__misc_ml Module

Module containing miscellaneous machine learning procedures

This module contains various procedures that are useful for machine learning tasks. These include shuffling data, splitting data into train and test sets, and padding data.


Uses

    • coreutils

Interfaces

public interface shuffle

Shuffle an array along one dimension

This procedure shuffles an array along one dimension. The array can be of any rank, but the dimension along which to shuffle must be specified. An optional index array can also be shuffled.

  • private subroutine shuffle_1Dilist(data, seed)

    Shuffle a 1D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(inout), dimension(:) :: data

    1D array to be shuffled

    integer, intent(in), optional :: seed

    Random seed

  • private subroutine shuffle_2Drdata(data, dim, seed)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(inout), dimension(:,:) :: data

    2D array to be shuffled

    integer, intent(in) :: dim

    Dimension along which to shuffle

    integer, intent(in), optional :: seed

    Random seed

  • private subroutine shuffle_3Didata(data, dim, seed)

    Shuffle a 3D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(inout), dimension(:,:,:) :: data

    3D array to be shuffled

    integer, intent(in) :: dim

    Dimension along which to shuffle

    integer, intent(in), optional :: seed

    Random seed

  • private subroutine shuffle_3Drdata(data, dim, seed)

    Shuffle a 3D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(inout), dimension(:,:,:) :: data

    3D array to be shuffled

    integer, intent(in) :: dim

    Dimension along which to shuffle

    integer, intent(in), optional :: seed

    Random seed

  • private subroutine shuffle_4Drdata(data, dim, seed)

    Shuffle a 4D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(inout), dimension(:,:,:,:) :: data

    4D array to be shuffled

    integer, intent(in) :: dim

    Dimension along which to shuffle

    integer, intent(in), optional :: seed

    Random seed

  • private subroutine shuffle_5Drdata(data, dim, seed)

    Shuffle a 5D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(inout), dimension(:,:,:,:,:) :: data

    5D array to be shuffled

    integer, intent(in) :: dim

    Dimension along which to shuffle

    integer, intent(in), optional :: seed

    Random seed

  • private subroutine shuffle_2Drdata_1Drlist(data, label, dim, seed, shuffle_list)

    Shuffle a 2D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(inout), dimension(:,:) :: data

    2D array to be shuffled

    real(kind=real32), intent(inout), dimension(:) :: label

    1D array to be shuffled

    integer, intent(in) :: dim

    Dimension along which to shuffle

    integer, intent(in), optional :: seed

    Random seed

    integer, intent(out), optional, dimension(size(data,dim)) :: shuffle_list

    Index array

  • private subroutine shuffle_3Didata_1Dilist(data, label, dim, seed)

    Shuffle a 3D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(inout), dimension(:,:,:) :: data

    3D array to be shuffled

    integer, intent(inout), dimension(:) :: label

    1D array to be shuffled

    integer, intent(in) :: dim

    Dimension along which to shuffle

    integer, intent(in), optional :: seed

    Random seed

  • private subroutine shuffle_3Didata_1Drlist(data, label, dim, seed)

    Shuffle a 3D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(inout), dimension(:,:,:) :: data

    3D array to be shuffled

    real(kind=real32), intent(inout), dimension(:) :: label

    1D array to be shuffled

    integer, intent(in) :: dim

    Dimension along which to shuffle

    integer, intent(in), optional :: seed

    Random seed

  • private subroutine shuffle_4Drdata_1Dilist(data, label, dim, seed)

    Shuffle a 4D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(inout), dimension(:,:,:,:) :: data

    4D array to be shuffled

    integer, intent(inout), dimension(:) :: label

    1D array to be shuffled

    integer, intent(in) :: dim

    Dimension along which to shuffle

    integer, intent(in), optional :: seed

    Random seed

  • private subroutine shuffle_5Drdata_1Dilist(data, label, dim, seed)

    Shuffle a 5D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(inout), dimension(:,:,:,:,:) :: data

    5D array to be shuffled

    integer, intent(inout), dimension(:) :: label

    1D array to be shuffled

    integer, intent(in) :: dim

    Dimension along which to shuffle

    integer, intent(in), optional :: seed

    Random seed

  • private subroutine shuffle_5Drdata_1Drlist(data, label, dim, seed, shuffle_list)

    Shuffle a 5D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(inout), dimension(:,:,:,:,:) :: data

    5D array to be shuffled

    real(kind=real32), intent(inout), dimension(:) :: label

    1D array to be shuffled

    integer, intent(in) :: dim

    Dimension along which to shuffle

    integer, intent(in), optional :: seed

    Random seed

    integer, intent(out), optional, dimension(size(data,dim)) :: shuffle_list

    Index array

public interface split

Split an array into train and test sets

This procedure splits an array into two sets along one dimension. The array can be of any rank, but the dimension along which to split must be specified. An optional index array can also be split. The size of the left and right splits can also be specified. The data can be shuffled before splitting.

  • private subroutine split_2Drdata_1Drlist(data, label, left_data, right_data, left_label, right_label, dim, left_size, right_size, shuffle, seed, split_list)

    Split a 2D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(in), dimension(:,:) :: data

    2D array to be split

    real(kind=real32), intent(in), dimension(:) :: label

    1D array to be split

    real(kind=real32), intent(out), allocatable, dimension(:,:) :: left_data

    2D arrays to store the left and right splits

    real(kind=real32), intent(out), allocatable, dimension(:,:) :: right_data

    2D arrays to store the left and right splits

    real(kind=real32), intent(out), allocatable, dimension(:) :: left_label

    1D arrays to store the left and right splits

    real(kind=real32), intent(out), allocatable, dimension(:) :: right_label

    1D arrays to store the left and right splits

    integer, intent(in) :: dim

    Dimension along which to split

    real(kind=real32), intent(in), optional :: left_size

    Size of the left and right splits

    real(kind=real32), intent(in), optional :: right_size

    Size of the left and right splits

    logical, intent(in), optional :: shuffle

    Shuffle the data before splitting

    integer, intent(in), optional :: seed

    Random seed

    integer, intent(out), optional, dimension(size(data,dim)) :: split_list

    Index array

  • private subroutine split_3Didata_1Dilist(data, label, left_data, right_data, left_label, right_label, dim, left_size, right_size, shuffle, seed, split_list)

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), dimension(:,:,:) :: data

    3D array to be split

    integer, intent(in), dimension(:) :: label

    1D array to be split

    integer, intent(out), allocatable, dimension(:,:,:) :: left_data

    3D arrays to store the left and right splits

    integer, intent(out), allocatable, dimension(:,:,:) :: right_data

    3D arrays to store the left and right splits

    integer, intent(out), allocatable, dimension(:) :: left_label

    1D arrays to store the left and right splits

    integer, intent(out), allocatable, dimension(:) :: right_label

    1D arrays to store the left and right splits

    integer, intent(in) :: dim

    Dimension along which to split

    real(kind=real32), intent(in), optional :: left_size

    Size of the left and right splits

    real(kind=real32), intent(in), optional :: right_size

    Size of the left and right splits

    logical, intent(in), optional :: shuffle

    Shuffle the data before splitting

    integer, intent(in), optional :: seed

    Random seed

    integer, intent(out), optional, dimension(size(data,dim)) :: split_list

    Index array

  • private subroutine split_3Didata_1Drlist(data, label, left_data, right_data, left_label, right_label, dim, left_size, right_size, shuffle, seed, split_list)

    Split a 3D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), dimension(:,:,:) :: data

    3D array to be split

    real(kind=real32), intent(in), dimension(:) :: label

    1D array to be split

    integer, intent(out), allocatable, dimension(:,:,:) :: left_data

    3D arrays to store the left and right splits

    integer, intent(out), allocatable, dimension(:,:,:) :: right_data

    3D arrays to store the left and right splits

    real(kind=real32), intent(out), allocatable, dimension(:) :: left_label

    1D arrays to store the left and right splits

    real(kind=real32), intent(out), allocatable, dimension(:) :: right_label

    1D arrays to store the left and right splits

    integer, intent(in) :: dim

    Dimension along which to split

    real(kind=real32), intent(in), optional :: left_size

    Size of the left and right splits

    real(kind=real32), intent(in), optional :: right_size

    Size of the left and right splits

    logical, intent(in), optional :: shuffle

    Shuffle the data before splitting

    integer, intent(in), optional :: seed

    Random seed

    integer, intent(out), optional, dimension(size(data,dim)) :: split_list

    Index array

  • private subroutine split_5Drdata(data, left, right, dim, left_size, right_size, shuffle, seed)

    Split a 5D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(in), dimension(:,:,:,:,:) :: data

    5D array to be split

    real(kind=real32), intent(out), allocatable, dimension(:,:,:,:,:) :: left

    5D arrays to store the left and right splits

    real(kind=real32), intent(out), allocatable, dimension(:,:,:,:,:) :: right

    5D arrays to store the left and right splits

    integer, intent(in) :: dim

    Dimension along which to split

    real(kind=real32), intent(in), optional :: left_size

    Size of the left and right splits

    real(kind=real32), intent(in), optional :: right_size

    Size of the left and right splits

    logical, intent(in), optional :: shuffle

    Shuffle the data before splitting

    integer, intent(in), optional :: seed

    Random seed

  • private subroutine split_5Drdata_1Drlist(data, label, left_data, right_data, left_label, right_label, dim, left_size, right_size, shuffle, seed, split_list)

    Split a 5D array along one dimension

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(in), dimension(:,:,:,:,:) :: data

    5D array to be split

    real(kind=real32), intent(in), dimension(:) :: label

    1D array to be split

    real(kind=real32), intent(out), allocatable, dimension(:,:,:,:,:) :: left_data

    5D arrays to store the left and right splits

    real(kind=real32), intent(out), allocatable, dimension(:,:,:,:,:) :: right_data

    5D arrays to store the left and right splits

    real(kind=real32), intent(out), allocatable, dimension(:) :: left_label

    1D arrays to store the left and right splits

    real(kind=real32), intent(out), allocatable, dimension(:) :: right_label

    1D arrays to store the left and right splits

    integer, intent(in) :: dim

    Dimension along which to split

    real(kind=real32), intent(in), optional :: left_size

    Size of the left and right splits

    real(kind=real32), intent(in), optional :: right_size

    Size of the left and right splits

    logical, intent(in), optional :: shuffle

    Shuffle the data before splitting

    integer, intent(in), optional :: seed

    Random seed

    integer, intent(out), optional, dimension(size(data,dim)) :: split_list

    Index array


Functions

private pure function get_padding_half(width) result(output)

Function to return half the padding width

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: width

Width of kernel/filter

Return Value integer

Half the padding width


Subroutines

public subroutine pad_data(data, data_padded, kernel_size, padding_method, sample_dim, channel_dim, constant)

Pad data for convolutional layers

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in), dimension(..) :: data

Data to be padded

real(kind=real32), intent(out), allocatable, dimension(..) :: data_padded

Padded data

integer, intent(in), dimension(..) :: kernel_size

Width of kernel/filter

character(len=*), intent(inout) :: padding_method

Padding method

integer, intent(in), optional :: sample_dim

Dimensions along which to pad

integer, intent(in), optional :: channel_dim

Dimensions along which to pad

real(kind=real32), intent(in), optional :: constant

Constant value for padding

public subroutine set_padding(pad, kernel_size, padding_method, verbose)

Set padding for convolutional layers

Arguments

Type IntentOptional Attributes Name
integer, intent(out) :: pad

Padding width

integer, intent(in) :: kernel_size

Width of kernel/filter

character(len=*), intent(inout) :: padding_method

Padding method

integer, intent(in), optional :: verbose

Verbosity level

private subroutine shuffle_1Dilist(data, seed)

Shuffle a 1D array along one dimension

Arguments

Type IntentOptional Attributes Name
integer, intent(inout), dimension(:) :: data

1D array to be shuffled

integer, intent(in), optional :: seed

Random seed

private subroutine shuffle_2Drdata(data, dim, seed)

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(inout), dimension(:,:) :: data

2D array to be shuffled

integer, intent(in) :: dim

Dimension along which to shuffle

integer, intent(in), optional :: seed

Random seed

private subroutine shuffle_2Drdata_1Drlist(data, label, dim, seed, shuffle_list)

Shuffle a 2D array along one dimension

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(inout), dimension(:,:) :: data

2D array to be shuffled

real(kind=real32), intent(inout), dimension(:) :: label

1D array to be shuffled

integer, intent(in) :: dim

Dimension along which to shuffle

integer, intent(in), optional :: seed

Random seed

integer, intent(out), optional, dimension(size(data,dim)) :: shuffle_list

Index array

private subroutine shuffle_3Didata(data, dim, seed)

Shuffle a 3D array along one dimension

Arguments

Type IntentOptional Attributes Name
integer, intent(inout), dimension(:,:,:) :: data

3D array to be shuffled

integer, intent(in) :: dim

Dimension along which to shuffle

integer, intent(in), optional :: seed

Random seed

private subroutine shuffle_3Didata_1Dilist(data, label, dim, seed)

Shuffle a 3D array along one dimension

Arguments

Type IntentOptional Attributes Name
integer, intent(inout), dimension(:,:,:) :: data

3D array to be shuffled

integer, intent(inout), dimension(:) :: label

1D array to be shuffled

integer, intent(in) :: dim

Dimension along which to shuffle

integer, intent(in), optional :: seed

Random seed

private subroutine shuffle_3Didata_1Drlist(data, label, dim, seed)

Shuffle a 3D array along one dimension

Arguments

Type IntentOptional Attributes Name
integer, intent(inout), dimension(:,:,:) :: data

3D array to be shuffled

real(kind=real32), intent(inout), dimension(:) :: label

1D array to be shuffled

integer, intent(in) :: dim

Dimension along which to shuffle

integer, intent(in), optional :: seed

Random seed

private subroutine shuffle_3Drdata(data, dim, seed)

Shuffle a 3D array along one dimension

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(inout), dimension(:,:,:) :: data

3D array to be shuffled

integer, intent(in) :: dim

Dimension along which to shuffle

integer, intent(in), optional :: seed

Random seed

private subroutine shuffle_4Drdata(data, dim, seed)

Shuffle a 4D array along one dimension

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(inout), dimension(:,:,:,:) :: data

4D array to be shuffled

integer, intent(in) :: dim

Dimension along which to shuffle

integer, intent(in), optional :: seed

Random seed

private subroutine shuffle_4Drdata_1Dilist(data, label, dim, seed)

Shuffle a 4D array along one dimension

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(inout), dimension(:,:,:,:) :: data

4D array to be shuffled

integer, intent(inout), dimension(:) :: label

1D array to be shuffled

integer, intent(in) :: dim

Dimension along which to shuffle

integer, intent(in), optional :: seed

Random seed

private subroutine shuffle_5Drdata(data, dim, seed)

Shuffle a 5D array along one dimension

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(inout), dimension(:,:,:,:,:) :: data

5D array to be shuffled

integer, intent(in) :: dim

Dimension along which to shuffle

integer, intent(in), optional :: seed

Random seed

private subroutine shuffle_5Drdata_1Dilist(data, label, dim, seed)

Shuffle a 5D array along one dimension

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(inout), dimension(:,:,:,:,:) :: data

5D array to be shuffled

integer, intent(inout), dimension(:) :: label

1D array to be shuffled

integer, intent(in) :: dim

Dimension along which to shuffle

integer, intent(in), optional :: seed

Random seed

private subroutine shuffle_5Drdata_1Drlist(data, label, dim, seed, shuffle_list)

Shuffle a 5D array along one dimension

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(inout), dimension(:,:,:,:,:) :: data

5D array to be shuffled

real(kind=real32), intent(inout), dimension(:) :: label

1D array to be shuffled

integer, intent(in) :: dim

Dimension along which to shuffle

integer, intent(in), optional :: seed

Random seed

integer, intent(out), optional, dimension(size(data,dim)) :: shuffle_list

Index array

private subroutine split_2Drdata_1Drlist(data, label, left_data, right_data, left_label, right_label, dim, left_size, right_size, shuffle, seed, split_list)

Split a 2D array along one dimension

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in), dimension(:,:) :: data

2D array to be split

real(kind=real32), intent(in), dimension(:) :: label

1D array to be split

real(kind=real32), intent(out), allocatable, dimension(:,:) :: left_data

2D arrays to store the left and right splits

real(kind=real32), intent(out), allocatable, dimension(:,:) :: right_data

2D arrays to store the left and right splits

real(kind=real32), intent(out), allocatable, dimension(:) :: left_label

1D arrays to store the left and right splits

real(kind=real32), intent(out), allocatable, dimension(:) :: right_label

1D arrays to store the left and right splits

integer, intent(in) :: dim

Dimension along which to split

real(kind=real32), intent(in), optional :: left_size

Size of the left and right splits

real(kind=real32), intent(in), optional :: right_size

Size of the left and right splits

logical, intent(in), optional :: shuffle

Shuffle the data before splitting

integer, intent(in), optional :: seed

Random seed

integer, intent(out), optional, dimension(size(data,dim)) :: split_list

Index array

private subroutine split_3Didata_1Dilist(data, label, left_data, right_data, left_label, right_label, dim, left_size, right_size, shuffle, seed, split_list)

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:,:,:) :: data

3D array to be split

integer, intent(in), dimension(:) :: label

1D array to be split

integer, intent(out), allocatable, dimension(:,:,:) :: left_data

3D arrays to store the left and right splits

integer, intent(out), allocatable, dimension(:,:,:) :: right_data

3D arrays to store the left and right splits

integer, intent(out), allocatable, dimension(:) :: left_label

1D arrays to store the left and right splits

integer, intent(out), allocatable, dimension(:) :: right_label

1D arrays to store the left and right splits

integer, intent(in) :: dim

Dimension along which to split

real(kind=real32), intent(in), optional :: left_size

Size of the left and right splits

real(kind=real32), intent(in), optional :: right_size

Size of the left and right splits

logical, intent(in), optional :: shuffle

Shuffle the data before splitting

integer, intent(in), optional :: seed

Random seed

integer, intent(out), optional, dimension(size(data,dim)) :: split_list

Index array

private subroutine split_3Didata_1Drlist(data, label, left_data, right_data, left_label, right_label, dim, left_size, right_size, shuffle, seed, split_list)

Split a 3D array along one dimension

Arguments

Type IntentOptional Attributes Name
integer, intent(in), dimension(:,:,:) :: data

3D array to be split

real(kind=real32), intent(in), dimension(:) :: label

1D array to be split

integer, intent(out), allocatable, dimension(:,:,:) :: left_data

3D arrays to store the left and right splits

integer, intent(out), allocatable, dimension(:,:,:) :: right_data

3D arrays to store the left and right splits

real(kind=real32), intent(out), allocatable, dimension(:) :: left_label

1D arrays to store the left and right splits

real(kind=real32), intent(out), allocatable, dimension(:) :: right_label

1D arrays to store the left and right splits

integer, intent(in) :: dim

Dimension along which to split

real(kind=real32), intent(in), optional :: left_size

Size of the left and right splits

real(kind=real32), intent(in), optional :: right_size

Size of the left and right splits

logical, intent(in), optional :: shuffle

Shuffle the data before splitting

integer, intent(in), optional :: seed

Random seed

integer, intent(out), optional, dimension(size(data,dim)) :: split_list

Index array

private subroutine split_5Drdata(data, left, right, dim, left_size, right_size, shuffle, seed)

Split a 5D array along one dimension

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in), dimension(:,:,:,:,:) :: data

5D array to be split

real(kind=real32), intent(out), allocatable, dimension(:,:,:,:,:) :: left

5D arrays to store the left and right splits

real(kind=real32), intent(out), allocatable, dimension(:,:,:,:,:) :: right

5D arrays to store the left and right splits

integer, intent(in) :: dim

Dimension along which to split

real(kind=real32), intent(in), optional :: left_size

Size of the left and right splits

real(kind=real32), intent(in), optional :: right_size

Size of the left and right splits

logical, intent(in), optional :: shuffle

Shuffle the data before splitting

integer, intent(in), optional :: seed

Random seed

private subroutine split_5Drdata_1Drlist(data, label, left_data, right_data, left_label, right_label, dim, left_size, right_size, shuffle, seed, split_list)

Split a 5D array along one dimension

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in), dimension(:,:,:,:,:) :: data

5D array to be split

real(kind=real32), intent(in), dimension(:) :: label

1D array to be split

real(kind=real32), intent(out), allocatable, dimension(:,:,:,:,:) :: left_data

5D arrays to store the left and right splits

real(kind=real32), intent(out), allocatable, dimension(:,:,:,:,:) :: right_data

5D arrays to store the left and right splits

real(kind=real32), intent(out), allocatable, dimension(:) :: left_label

1D arrays to store the left and right splits

real(kind=real32), intent(out), allocatable, dimension(:) :: right_label

1D arrays to store the left and right splits

integer, intent(in) :: dim

Dimension along which to split

real(kind=real32), intent(in), optional :: left_size

Size of the left and right splits

real(kind=real32), intent(in), optional :: right_size

Size of the left and right splits

logical, intent(in), optional :: shuffle

Shuffle the data before splitting

integer, intent(in), optional :: seed

Random seed

integer, intent(out), optional, dimension(size(data,dim)) :: split_list

Index array