hnn_core.optimization.Optimizer#
- class hnn_core.optimization.Optimizer(initial_net, tstop, constraints, set_params, initial_params=None, solver='bayesian', obj_fun='dipole_rmse', max_iter=200)[source]#
Methods
fit(**obj_fun_kwargs)Runs optimization routine.
plot_convergence([ax, show])Convergence plot.
- fit(**obj_fun_kwargs)[source]#
Runs optimization routine.
- Parameters:
- targetinstance of Dipole (Required if obj_fun=’dipole_rmse’)
A dipole object with experimental data.
- n_trialsint (Optional if obj_fun=’dipole_rmse’)
Number of trials to simulate and average.
- f_bandslist of tuples (Required if obj_fun=’maximize_psd’)
Lower and higher limit for each frequency band.
- relative_bandpowerlist of float | float (Required if obj_fun=’maximize_psd’)
Weight for each frequency band in f_bands. If a single float is provided, the same weight is applied to all frequency bands.
- sigma0float| array-like (Only used if solver=’cma’)
Initial standard deviation of CME-ES algorithm. If float, sigma0 is scaled by bounds defined in the constraints for each parameter. If array-like, The length of sigma0 must equal the length of constraints. Default: 0.25
- popsizeint (Only used if solver=’cma’)
Number of parameter samples simulated per epoch. Default: 16
- n_jobsint (Only used if solver=’cma’)
The number of jobs to start in parallel. If None, then 1 trial will be started without parallelism.
- tolfunfloat
Termination criteria. Stops if the range of the best objective function values of the last 10 + ((30 * n_parameters) / popsize) generations and all function values of the recent generation is below tolfun. Default 0.01.
- dtfloat
The integration time step of h.CVode (ms). Default: 0.025 ms
- scale_factorfloat, optional
The dipole scale factor.
- smooth_window_lenfloat, optional
The smooth window length.
- seedint, optional (Only used if solver=’cma’)
Optional seed for random number generator of optimizer.
- verbosebool
If True, print build steps and simulation progress to console. Default: True.
Notes
When defining sigma0 for CMA-ES as a float, the sigma0 applied to each parameter is calculated as sigma0 * (upper_bound - lower_bound) based on the constraints. It is recommended to choose a sigma0 such that the optimum is expected to lie within about initial_params +- 3*sigma0. A smaller sigma0 searches closer to initial_params.
When defining popsize for CMA-ES, it is recommended to increase popsize relative to the number of parameters being optimized (N). 4+3*log(N)