Update the readout
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(duvenaud_msgpass_layer_type), | intent(inout), | target | :: | this |
Instance of the message passing layer |
subroutine update_readout_duvenaud(this) !! Update the readout implicit none ! Arguments class(duvenaud_msgpass_layer_type), intent(inout), target :: this !! Instance of the message passing layer ! Local variables integer :: s, t, batch_size !! Loop indices type(array_type), pointer :: ptr1, ptr2, ptr3, ptr_params, ptr_z batch_size = size(this%z,2) call this%output(1,1)%zero_grad() do t = 1, this%num_time_steps, 1 do s = 1, batch_size, 1 ptr_params => this%params(t+this%num_time_steps) ptr_z => this%z(t,s) ptr1 => matmul( & ptr_params, & ptr_z & ) ptr2 => this%activation_readout%apply( ptr1 ) if(t.eq.1.and.s.eq.1)then ptr3 => & sum( ptr2, dim = 2, new_dim_index=s, new_dim_size=batch_size ) else ptr3 => ptr3 + & sum( ptr2, dim = 2, new_dim_index=s, new_dim_size=batch_size ) end if end do end do call this%output(1,1)%assign_and_deallocate_source(ptr3) this%output(1,1)%is_temporary = .false. end subroutine update_readout_duvenaud