Given input x and output y, evaluates the position of the maximum value of the output and returns the number of matches relative to the size of the dataset.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(in) | :: | self | |||
| real(kind=rk), | intent(in) | :: | x(:,:) | |||
| real(kind=rk), | intent(in) | :: | y(:,:) |
pure real(rk) function accuracy(self, x, y)
!! Given input x and output y, evaluates the position of the
!! maximum value of the output and returns the number of matches
!! relative to the size of the dataset.
class(network_type), intent(in) :: self
real(rk), intent(in) :: x(:,:), y(:,:)
integer(ik) :: i, good
good = 0
do i = 1, size(x, dim=2)
if (all(maxloc(self % output(x(:,i))) == maxloc(y(:,i)))) then
good = good + 1
end if
end do
accuracy = real(good, kind=rk) / size(x, dim=2)
end function accuracy