wandb_sweep_next_params Subroutine

public subroutine wandb_sweep_next_params(params_json, timeout_s)

Block until the sweep agent has started the next run and populated wandb.config with the sweep-sampled hyperparameters.

                object string, e.g. {"lr":0.01,"hidden":32}.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(out) :: params_json

Receives the sampled hyperparameters as a JSON

real(kind=c_double), intent(in), optional :: timeout_s

Seconds to wait before giving up (default: 120.0).


Source Code

  subroutine wandb_sweep_next_params(params_json, timeout_s)
    !! Block until the sweep agent has started the next run and populated
    !! wandb.config with the sweep-sampled hyperparameters.
    !!
    !! @param params_json  Receives the sampled hyperparameters as a JSON
    !!                     object string, e.g. {"lr":0.01,"hidden":32}.
    !! @param timeout_s    Seconds to wait before giving up (default: 120.0).
    character(len=*),          intent(out) :: params_json
    real(c_double), optional,  intent(in)  :: timeout_s

    character(kind=c_char), dimension(4096) :: c_buf
    real(c_double) :: tval
    integer(c_int) :: ok
    integer :: i

    tval = 120.0_c_double
    if(present(timeout_s)) tval = timeout_s

    ok = wandb_sweep_params_c(c_buf, int(4096, c_int), tval)

    if(ok == 0_c_int)then
       write(0,*) "[wf] WARNING: wandb_sweep_next_params timed out."
       params_json = '{}'
       return
    end if

    params_json = ' '
    do i = 1, len(params_json)
       if(c_buf(i) == c_null_char) exit
       params_json(i:i) = c_buf(i)
    end do

  end subroutine wandb_sweep_next_params