loss Function

private pure function loss(self, x, y)

Given input x and expected output y, returns the loss of the network.

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 loss(self, x, y)
    !! Given input x and expected output y, returns the loss of the network.
    class(network_type), intent(in) :: self
    real(rk), intent(in) :: x(:), y(:)
    loss = 0.5 * sum((y - self % output(x))**2) / size(x)
  end function loss