phygnn.base.GradientUtils

class GradientUtils[source]

Bases: ABC

TF 2.0 gradient descent utilities.

Methods

calc_loss(y_true, y_predicted)

Placeholder for loss function

predict(x)

Placeholder for loss function

run_gradient_descent(x, y_true)

Run gradient descent for one mini-batch of (x, y_true) and adjust NN weights

abstract predict(x)[source]

Placeholder for loss function

Parameters:

x (np.ndarray) – Input feature data to predict on in a >=2D array.

Returns:

y_predicted (tf.Tensor) – Model-predicted output data in a >=2D tensor.

abstract calc_loss(y_true, y_predicted)[source]

Placeholder for loss function

Parameters:
  • y_true (np.ndarray) – Known output data in a >=2D array.

  • y_predicted (tf.Tensor) – Model-predicted output data in a >=2D tensor.

Returns:

loss (tf.tensor) – Loss function output comparing the y_predicted against y_true.

run_gradient_descent(x, y_true)[source]

Run gradient descent for one mini-batch of (x, y_true) and adjust NN weights

Parameters:
  • x (np.ndarray) – Feature data in a >=2D array. Generally speaking, the data should always have the number of observations in the first axis and the number of features/channels in the last axis. Spatial and temporal dimensions can be used in intermediate axes.

  • y_true (np.ndarray) – Known y values.

Returns:

loss (tf.Tensor) – Loss function output comparing the y_predicted against y_true.