Read the optimiser settings from a file
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(network_type), | intent(inout) | :: | this |
Instance of network |
||
| integer, | intent(in) | :: | unit |
File unit |
module subroutine read_optimiser_settings(this, unit) !! Read the optimiser settings from a file use coreutils, only: to_lower, to_upper, icount use athena__optimiser, only: & sgd_optimiser_type, adam_optimiser_type, rmsprop_optimiser_type, & adagrad_optimiser_type, base_optimiser_type implicit none ! Arguments class(network_type), intent(inout) :: this !! Instance of network integer, intent(in) :: unit !! File unit ! Local variables integer :: stat !! File status character(20) :: optimiser_name !! Name of the optimiser character(256) :: buffer, err_msg, tmp !! Buffer for reading lines, error message ! Read until end of optimiser settings read(unit,'(A)',iostat=stat) buffer if(stat.ne.0)then write(err_msg,'("file encountered error (EoF?) before END ",A)') & to_upper(this%name) call stop_program(err_msg) return end if read(buffer,*) tmp, optimiser_name select case(trim(adjustl(to_lower(optimiser_name)))) case("sgd") this%optimiser = sgd_optimiser_type() case("adam") this%optimiser = adam_optimiser_type() case("rmsprop") this%optimiser = rmsprop_optimiser_type() case("adagrad") this%optimiser = adagrad_optimiser_type() case("","base") this%optimiser = base_optimiser_type() case default write(err_msg,'("Unrecognised optimiser: ",A)') trim(adjustl(optimiser_name)) call stop_program(err_msg) return end select call this%optimiser%read(unit) end subroutine read_optimiser_settings