2D Branin

class deepobs.two_d.noisy_branin.set_up(batch_size=128, size=1000, noise_level=6, starting_point=[2.5, 12.5], weight_decay=None)[source]

Simple 2D Noisy Branin Loss Function:

\((v - 5.1/(4 \cdot \pi^2) u^2 + 5/ \pi u - 6)^2 \cdot y + 10 \cdot (1-1/(8 \cdot \pi)) \cdot \cos(u) \cdot x + 10\)

where X and Y are normally distributed with mean 1.0 and sigma given by the noise_level.

Parameters:
  • batch_size (int) -- Batch size of the data points. Defaults to 128.
  • size (int) -- Size of the training set. Defaults to 1000.
  • noise_level (float) -- Noise level of the training set. All training points are sampled from a gaussian distribution with the noise level as the standard deviation. Defaults to 6.0.
  • starting_point (list) -- Coordinates of the starting point of the optimization process. Defaults to [2.5, 12.5].
  • weight_decay (float) -- Weight decay factor. In this model there is no weight decay implemented. Defaults to None.
data_loading

Data loading class for 2D functions, two_d_input.data_loading.

Type:deepobs.data_loading
losses

Tensor of size batch_size containing the individual losses per data point.

Type:tf.Tensor
accuracy

Tensor containing the accuracy of the model. As there is no accuracy when the loss function is given directly, we set it to 0.

Type:tf.Tensor
train_init_op

A TensorFlow operation to be performed before starting every training epoch.

Type:tf.Operation
train_eval_init_op

A TensorFlow operation to be performed before starting every training eval epoch.

Type:tf.Operation
test_init_op

A TensorFlow operation to be performed before starting every test evaluation phase.

Type:tf.Operation
anim_run(u_history, v_history, loss_history, name='Optimizer Trajectory')[source]

Animate the history of weights (u, v) and the corresponding loss of an optimizer. Plot the deterministic Branin as well.

Parameters:
  • u_history (list) -- List of u values (first parameter) as passed by the optimizer.
  • v_history (list) -- List of v values (second parameter) as passed by the optimizer.
  • loss_history (list) -- List of loss values as passed by the optimizer. Could be train or test loss.
  • name (str) -- Name of the optimizer. Defaults to "Optimizer Trajectory".
Returns:

Animation object showing the optimizer's trajectory per iteration.

Return type:

matplotlib.animation.FuncAnimation

branin(u, v)[source]

Deterministic version of Branin function.

Parameters:
  • u (float) -- Coordinate of the first parameter.
  • v (float) -- Coordinate of the second parameter.
Returns:

Function value of the deterministic Branin function at (u,v).

Return type:

float

get()[source]

Returns the losses and the accuray of the model.

Returns:Tupel consisting of the losses and the accuracy.
Return type:tupel
plot_run(u_history, v_history, loss_history)[source]

Plot the history of weights (u, v) and the corresponding loss of an optimizer. Plot the Deterministic Branin as well.

Parameters:
  • u_history (list) -- List of u values (first parameter) as passed by the optimizer.
  • v_history (list) -- List of v values (second parameter) as passed by the optimizer.
  • loss_history (list) -- List of loss values as passed by the optimizer. Could be train or test loss.
Returns:

Plot with the deterministic Branin and the optimizers trajectory.

Return type:

fig

set_up(starting_point=[2.5, 12.5], weight_decay=None)[source]

Sets up the test problem.

Parameters:
  • starting_point (list) -- Coordinates of the starting point of the optimization process. Defaults to [2.5, 12.5].
  • weight_decay (float) -- Weight decay factor. In this model there is no weight decay implemented. Defaults to None.
Returns:

Tupel consisting of the losses and the accuracy.

Return type:

tupel