Given input x and expected output y, returns the loss of the network.
| 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 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