mod_mnist Module

Procedures to work with MNIST dataset, usable with data format as provided in this repo and not the original data format (idx).

TODO make MNIST work with arbitrary precision


Uses

  • module~~mod_mnist~~UsesGraph module~mod_mnist mod_mnist module~mod_io mod_io module~mod_mnist->module~mod_io module~mod_kinds mod_kinds module~mod_mnist->module~mod_kinds iso_fortran_env iso_fortran_env module~mod_mnist->iso_fortran_env module~mod_io->module~mod_kinds module~mod_kinds->iso_fortran_env

Contents


Functions

public pure function label_digits(labels) result(res)

Converts an array of MNIST labels into a form that can be input to the network_type instance.

Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: labels(:)

Return Value real(kind=rk) (10,size(labels))

private pure function digits(x)

Returns an array of 10 reals, with zeros everywhere and a one corresponding to the input number, for example: digits(0) = [1., 0., 0., 0., 0., 0., 0., 0., 0., 0.] digits(1) = [0., 1., 0., 0., 0., 0., 0., 0., 0., 0.] digits(6) = [0., 0., 0., 0., 0., 0., 1., 0., 0., 0.]

Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: x

Return Value real(kind=rk) (10)


Subroutines

public subroutine load_mnist(tr_images, tr_labels, te_images, te_labels, va_images, va_labels)

Loads the MNIST dataset into arrays.

Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(inout), allocatable:: tr_images(:,:)
real(kind=rk), intent(inout), allocatable:: tr_labels(:)
real(kind=rk), intent(inout), allocatable:: te_images(:,:)
real(kind=rk), intent(inout), allocatable:: te_labels(:)
real(kind=rk), intent(inout), optional allocatable:: va_images(:,:)
real(kind=rk), intent(inout), optional allocatable:: va_labels(:)

public subroutine print_image(images, labels, n)

Prints a single image and label to screen.

Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: images(:,:)
real(kind=rk), intent(in) :: labels(:)
integer(kind=ik), intent(in) :: n