2D Rosenbrock

class deepobs.two_d.noisy_rosenbrock.set_up(batch_size=128, size=1000, noise_level=3, starting_point=[-0.5, 1.5], weight_decay=None)[source]

Simple 2D Noisy Beale Loss Function:

\((1 - u)^2 + 100 \cdot x \cdot (v - u^2)^2\)

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 3.0.
  • starting_point (list) -- Coordinates of the starting point of the optimization process. Defaults to [-0.5, 1.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 Rosenbrock 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

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 Rosenbrock 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 beale and the optimizers trajectory.

Return type:

fig

rosenbrock(u, v)[source]

Deterministic version of Rosenbrock function.

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

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

Return type:

float

set_up(starting_point=[-0.5, 1.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 [-0.5, 1.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