Get the loss for the output
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout), | target | :: | this |
Instance of network |
|
| integer, | intent(in) | :: | start_index |
Start and end batch indices |
||
| integer, | intent(in) | :: | end_index |
Start and end batch indices |
Loss value
module function loss_eval(this, start_index, end_index) result(loss) !! Get the loss for the output implicit none ! Arguments class(network_type), intent(inout), target :: this !! Instance of network integer, intent(in) :: start_index, end_index !! Start and end batch indices type(array_type), pointer :: loss !! Loss value ! Local variables integer :: i, s !! Loop index type(array_type), pointer :: expected(:,:), predicted(:,:) if(this%use_graph_output)then expected(1:2, 1: end_index - start_index + 1) => & this%expected_array( :, start_index:end_index ) else allocate(expected(size(this%expected_array,1), size(this%expected_array,2))) do s = 1, size(this%expected_array,2) do i = 1, size(this%expected_array,1) call expected(i,s)%allocate( & array_shape = [ & this%expected_array(i,s)%shape, & size(this%expected_array(i,s)%val,2) & ] & ) expected(i,s)%val = this%expected_array(i,s)%val(:, & start_index:end_index:1) end do end do end if predicted => this%model(this%leaf_vertices(1))%layer%output loss => this%loss%compute( & predicted, & expected & ) end function loss_eval