| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | module athena__initialiser_zeros | ||
| 2 | !! Module containing the implementation of the Zeros initialiser | ||
| 3 | !! | ||
| 4 | !! This module contains the implementation of the Zeros initialiser | ||
| 5 | !! for the weights and biases of a layer | ||
| 6 | use coreutils, only: real32 | ||
| 7 | use athena__misc_types, only: base_init_type | ||
| 8 | implicit none | ||
| 9 | |||
| 10 | |||
| 11 | private | ||
| 12 | |||
| 13 | public :: zeros_init_type | ||
| 14 | |||
| 15 | |||
| 16 | type, extends(base_init_type) :: zeros_init_type | ||
| 17 | !! Type for the Zeros initialiser | ||
| 18 | contains | ||
| 19 | procedure, pass(this) :: initialise => zeros_initialise | ||
| 20 | !! Initialise the weights and biases using the Zeros distribution | ||
| 21 | end type zeros_init_type | ||
| 22 | |||
| 23 | |||
| 24 | interface zeros_init_type | ||
| 25 | module function initialiser_zeros_setup() result(initialiser) | ||
| 26 | !! Interface for the Zeros initialiser | ||
| 27 | type(zeros_init_type) :: initialiser | ||
| 28 | !! Zeros initialiser object | ||
| 29 | end function initialiser_zeros_setup | ||
| 30 | end interface zeros_init_type | ||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | contains | ||
| 35 | |||
| 36 | !############################################################################### | ||
| 37 | − | module function initialiser_zeros_setup() result(initialiser) | |
| 38 | !! Interface for the Zeros initialiser | ||
| 39 | implicit none | ||
| 40 | |||
| 41 | type(zeros_init_type) :: initialiser | ||
| 42 | !! Zeros initialiser object | ||
| 43 | |||
| 44 | − | initialiser%name = "zeros" | |
| 45 | |||
| 46 | − | end function initialiser_zeros_setup | |
| 47 | !############################################################################### | ||
| 48 | |||
| 49 | |||
| 50 | !############################################################################### | ||
| 51 | − | pure subroutine zeros_initialise(this, input, fan_in, fan_out, spacing) | |
| 52 | !! Initialise the weights and biases using the Zeros distribution | ||
| 53 | implicit none | ||
| 54 | |||
| 55 | ! Arguments | ||
| 56 | class(zeros_init_type), intent(inout) :: this | ||
| 57 | !! Instance of the Zeros initialiser | ||
| 58 | real(real32), dimension(..), intent(out) :: input | ||
| 59 | !! Weights and biases to initialise | ||
| 60 | integer, optional, intent(in) :: fan_in, fan_out | ||
| 61 | !! Number of input and output parameters | ||
| 62 | integer, dimension(:), optional, intent(in) :: spacing | ||
| 63 | !! Spacing of the input and output units | ||
| 64 | |||
| 65 | select rank(input) | ||
| 66 | rank(0) | ||
| 67 | − | input = 0._real32 | |
| 68 | rank(1) | ||
| 69 | − | input = 0._real32 | |
| 70 | rank(2) | ||
| 71 | − | input = 0._real32 | |
| 72 | rank(3) | ||
| 73 | − | input = 0._real32 | |
| 74 | rank(4) | ||
| 75 | − | input = 0._real32 | |
| 76 | rank(5) | ||
| 77 | − | input = 0._real32 | |
| 78 | rank(6) | ||
| 79 | − | input = 0._real32 | |
| 80 | end select | ||
| 81 | |||
| 82 | − | end subroutine zeros_initialise | |
| 83 | !############################################################################### | ||
| 84 | |||
| 85 | − | end module athena__initialiser_zeros | |
| 86 |