Optimise input to match a target output (real inputs). Wraps the array_type implementation after converting real arrays.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout), | target | :: | this |
Instance of the network |
|
| real(kind=real32), | intent(in), | dimension(:,:) | :: | target |
Target output values |
|
| real(kind=real32), | intent(in), | dimension(:,:) | :: | x_init |
Initial input values |
|
| class(base_optimiser_type), | intent(in), | optional | :: | optimiser |
Optimiser for input updates (defaults to network optimiser) |
|
| integer, | intent(in) | :: | steps |
Number of optimisation iterations |
Optimised input
module function inverse_design_real( & this, target, x_init, optimiser, steps & ) result(x_opt) !! Optimise input to match a target output (real inputs). !! Wraps the array_type implementation after converting real arrays. implicit none ! Arguments class(network_type), intent(inout), target :: this !! Instance of the network real(real32), dimension(:,:), intent(in) :: target !! Target output values real(real32), dimension(:,:), intent(in) :: x_init !! Initial input values class(base_optimiser_type), optional, intent(in) :: optimiser !! Optimiser for input updates (defaults to network optimiser) integer, intent(in) :: steps !! Number of optimisation iterations real(real32), dimension(size(x_init,1), size(x_init,2)) :: x_opt !! Optimised input ! Local variables type(array_type), pointer :: target_arr(:,:), x_init_arr(:,:), x_opt_arr(:,:) !! Working input and target as array_type !--------------------------------------------------------------------------- ! Convert real arrays to array_type !--------------------------------------------------------------------------- allocate(target_arr(1,1), x_init_arr(1,1), x_opt_arr(1,1)) call target_arr(1,1)%allocate(source=target) call x_init_arr(1,1)%allocate(source=x_init) !--------------------------------------------------------------------------- ! Delegate to array_type implementation !--------------------------------------------------------------------------- x_opt_arr = this%inverse_design_array_2d( & target_arr, x_init_arr, optimiser, steps & ) x_opt = x_opt_arr(1,1)%val call target_arr(1,1)%deallocate() call x_init_arr(1,1)%deallocate() call x_opt_arr(1,1)%deallocate() deallocate(target_arr, x_init_arr, x_opt_arr) end function inverse_design_real