torchmin.Minimizer¶
-
class
torchmin.Minimizer(params, method='bfgs', **minimize_kwargs)[source]¶ A general-purpose PyTorch optimizer for unconstrained function minimization.
Warning
This optimizer doesn’t support per-parameter options and parameter groups (there can be only one).
Warning
Right now all parameters have to be on a single device. This will be improved in the future.
- Parameters
params (iterable) – An iterable of
torch.Tensors. Specifies what Tensors should be optimized.method (str) – Minimization method (algorithm) to use. Must be one of the methods offered in
torchmin.minimize(). Defaults to ‘bfgs’.**minimize_kwargs (dict) – Additional keyword arguments that will be passed to
torchmin.minimize().
-
__init__(params, method='bfgs', **minimize_kwargs)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(params[, method])Initialize self.
add_param_group(param_group)Add a param group to the
Optimizers param_groups.closure(x)dir_evaluate(x, t, d)load_state_dict(state_dict)Loads the optimizer state.
profile_hook_step(func)register_load_state_dict_post_hook(hook[, …])Register a load_state_dict post-hook which will be called after
load_state_dict()is called. It should have the following signature::.register_load_state_dict_pre_hook(hook[, …])Register a load_state_dict pre-hook which will be called before
load_state_dict()is called. It should have the following signature::.register_state_dict_post_hook(hook[, prepend])Register a state dict post-hook which will be called after
state_dict()is called. It should have the following signature::.register_state_dict_pre_hook(hook[, prepend])Register a state dict pre-hook which will be called before
state_dict()is called. It should have the following signature::.register_step_post_hook(hook)Register an optimizer step post hook which will be called after optimizer step. It should have the following signature::.
register_step_pre_hook(hook)Register an optimizer step pre hook which will be called before optimizer step. It should have the following signature::.
state_dict()Returns the state of the optimizer as a
dict.step(closure)Perform an optimization step.
zero_grad([set_to_none])Resets the gradients of all optimized
torch.Tensors.Attributes
OptimizerPostHookalias of Callable[[typing_extensions.Self, Tuple[Any, …], Dict[str, Any]], None]
OptimizerPreHookalias of Callable[[typing_extensions.Self, Tuple[Any, …], Dict[str, Any]], Optional[Tuple[Tuple[Any, …], Dict[str, Any]]]]
nfev