accuracy_eval Module Function

module function accuracy_eval(this, output, start_index, end_index) result(accuracy)

Get the loss for the output

Arguments

Type IntentOptional Attributes Name
class(network_type), intent(in) :: this

Instance of network

class(*), intent(in), dimension(:,:) :: output

Output

integer, intent(in) :: start_index

Start and end batch indices

integer, intent(in) :: end_index

Start and end batch indices

Return Value real(kind=real32)

Loss value


Source Code

  module function accuracy_eval(this, output, start_index, end_index) &
       result(accuracy)
    !! Get the loss for the output
    implicit none

    ! Arguments
    class(network_type), intent(in) :: this
    !! Instance of network
    class(*), dimension(:,:), intent(in) :: output
    !! Output
    integer, intent(in) :: start_index, end_index
    !! Start and end batch indices

    real(real32) :: accuracy
    !! Loss value

    ! Local variables
    integer :: s, s_idx
    !! Loop index

    accuracy = 0._real32
    select type(output)
    type is(graph_type)
       do s = start_index, end_index, 1
          s_idx = s - start_index + 1
          accuracy = accuracy + sum( this%get_accuracy( &
               this%model(this%leaf_vertices(1))%layer%output(1,s_idx)%val, &
               output(1,s)%vertex_features &
          ) ) / output(1,s)%num_vertices
          if( &
               this%model(this%leaf_vertices(1))%layer%output_shape(2).gt.0 &
          )then
             accuracy = accuracy + sum( this%get_accuracy( &
                  this%model(this%leaf_vertices(1))%layer%output(2,s_idx)%val, &
                  output(1,s)%edge_features &
             ) ) / output(1,s)%num_edges
          end if
       end do
    type is(real(real32))
       accuracy = sum( &
            this%get_accuracy( &
                 this%model(this%leaf_vertices(1))%layer%output(1,1)%val, &
                 output(:,start_index:end_index:1) &
            ))
    type is(integer)
       accuracy = sum( &
            this%get_accuracy( &
                 this%model(this%leaf_vertices(1))%layer%output(1,1)%val, &
                 real(output(:,start_index:end_index:1),real32) &
            ))
    class is(array_type)
       accuracy = sum( &
            this%get_accuracy( &
                 this%model(this%leaf_vertices(1))%layer%output(1,1)%val, &
                 output(1,1)%val(:,start_index:end_index:1) &
            ))
    end select
    accuracy = accuracy / real(end_index - start_index + 1, real32)

  end function accuracy_eval