restore_mode Module Subroutine

module subroutine restore_mode(this, mode_store)

Restore the training/inference mode of each layer from a stored array.

Arguments

Type IntentOptional Attributes Name
class(network_type), intent(inout) :: this

Instance of network

logical, intent(in), dimension(:) :: mode_store

Array storing the mode of each layer .true. = inference, .false. = training


Source Code

  module subroutine restore_mode(this, mode_store)
    !! Restore the training/inference mode of each layer from a stored array.
    implicit none

    ! Arguments
    class(network_type), intent(inout) :: this
    !! Instance of network
    logical, dimension(:), intent(in) :: mode_store
    !! Array storing the mode of each layer
    !! .true. = inference, .false. = training

    ! Local variables
    integer :: l
    !! Loop index

    if(.not.allocated(this%model)) return
    if(size(mode_store) .ne. this%num_layers)then
       call stop_program("mode_store size does not match number of layers")
       return
    end if
    do l = 1, this%num_layers
       this%model(l)%layer%inference = mode_store(l)
    end do

  end subroutine restore_mode