physbo.opt package

Module contents

class physbo.opt.Adam(params, grad, options={})[source]

Bases: object

Optimizer of f(x) with the adam method

params

current input, x

Type:

numpy.ndarray

nparams

dimension

Type:

int

grad

gradient function, g(x) = f’(x)

Type:

function

m
Type:

numpy.ndarray

v
Type:

numpy.ndarray

epoch

the number of update already done

Type:

int

max_epoch

the maximum number of update

Type:

int

alpha
Type:

float

beta
Type:

float

gamma
Type:

float

epsilon
Type:

float

Parameters:
  • params (numpy.ndarray) – Initial input vector x.

  • grad (callable) – Gradient function g(x) = f'(x); called as grad(params, *args, **kwargs).

  • options (dict) –

    Hyperparameters for the adam method

    • ”alpha” (default: 0.001)

    • ”beta” (default: 0.9)

    • ”gamma” (default: 0.9999)

    • ”epsilon” (default: 1e-8)

    • ”max_epoch” (default: 4000)

run(*args, **kwargs)[source]

Run max_epoch update steps in place on self.params.

Parameters:
  • args – Passed through to self.grad at each step.

  • kwargs – Passed through to self.grad at each step.

set_params(params)[source]

Set the current input vector.

Parameters:

params (numpy.ndarray) – New input vector x.

update(params, *args, **kwargs)[source]

calculates the updates of params

Parameters:
  • params (numpy.ndarray) – input

  • args – will be passed to self.grad

  • kwargs – will be passed to self.grad

Returns:

update of params

Return type:

numpy.ndarray