Use forward propagation to compute the output of the network. This specific procedure is for a single sample of 1-d input data.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | self | |||
| real(kind=rk), | intent(in) | :: | x(:) |
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