output_single Function

private pure function output_single(self, x) result(a)

Use forward propagation to compute the output of the network. This specific procedure is for a single sample of 1-d input data.

Arguments

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

Return Value real(kind=rk), allocatable,(:)


Calls

proc~~output_single~~CallsGraph proc~output_single output_single layers layers proc~output_single->layers

Contents

Source Code


Source Code

  pure function output_single(self, x) result(a)
    !! Use forward propagation to compute the output of the network.
    !! This specific procedure is for a single sample of 1-d input data.
    class(network_type), intent(in) :: self
    real(rk), intent(in) :: x(:)
    real(rk), allocatable :: a(:)
    integer(ik) :: n
    associate(layers => self % layers)
      a = self % layers(2) % activation(matmul(transpose(layers(1) % w), x) + layers(2) % b)
      do n = 3, size(layers)
        a = self % layers(n) % activation(matmul(transpose(layers(n-1) % w), a) + layers(n) % b)
      end do
    end associate
  end function output_single