fwdprop Subroutine

private pure subroutine fwdprop(self, x)

Performs the forward propagation and stores arguments to activation functions and activations themselves for use in backprop.

Arguments

Type IntentOptional AttributesName
class(network_type), intent(inout) :: self
real(kind=rk), intent(in) :: x(:)

Calls

proc~~fwdprop~~CallsGraph proc~fwdprop fwdprop layers layers proc~fwdprop->layers

Contents

Source Code


Source Code

  pure subroutine fwdprop(self, x)
    !! Performs the forward propagation and stores arguments to activation
    !! functions and activations themselves for use in backprop.
    class(network_type), intent(in out) :: self
    real(rk), intent(in) :: x(:)
    integer(ik) :: n
    associate(layers => self % layers)
      layers(1) % a = x
      do n = 2, size(layers)
        layers(n) % z = matmul(transpose(layers(n-1) % w), layers(n-1) % a) + layers(n) % b
        layers(n) % a = self % layers(n) % activation(layers(n) % z)
      end do
    end associate
  end subroutine fwdprop