accuracy Function

private pure 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.

Arguments

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

Return Value real(kind=rk)


Contents

Source Code


Source Code

  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