reset_gradients Module Subroutine

module subroutine reset_gradients(this)

Reset gradients

Arguments

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

Instance of network


Source Code

  module subroutine reset_gradients(this)
    !! Reset gradients
    implicit none

    ! Arguments
    class(network_type), intent(inout) :: this
    !! Instance of network

    ! Local variables
    integer :: l, i
    !! Loop index

    do l = 1, this%num_layers
       select type(current => this%model(l)%layer)
       class is(learnable_layer_type)
          do i = 1, size(current%params)
             call current%params(i)%zero_grad()
          end do
       end select
    end do

  end subroutine reset_gradients