garage.tf.regressors.base module

Regressor base classes without Parameterized.

class Regressor(input_shape, output_dim, name)[source]

Bases: abc.ABC

Regressor base class.

Parameters:
  • input_shape (tuple[int]) – Input shape.
  • output_dim (int) – Output dimension.
  • name (str) – Name of the regressor.
fit(xs, ys)[source]

Fit with input data xs and label ys.

Parameters:
  • xs (numpy.ndarray) – Input data.
  • ys (numpy.ndarray) – Label of input data.
flat_to_params(flattened_params, **tags)[source]

Unflatten tensors according to their respective shapes.

Parameters:
  • flattened_params (np.ndarray) – A numpy array of flattened params.
  • tags (dict) – Some common tags include ‘regularizable’ and
  • 'trainable'
Returns:

A list of parameters reshaped to the shapes specified.

Return type:

tensors (List[np.ndarray])

get_param_shapes(**tags)[source]

Get the list of shapes for the parameters.

Parameters:
  • tags (dict) – Some common tags include ‘regularizable’ and
  • 'trainable'
Returns:

A list of shapes of each parameter.

Return type:

List[tuple[int]]

get_param_values(**tags)[source]

Get the list of values for the parameters.

Parameters:
  • tags (dict) – Some common tags include ‘regularizable’ and
  • 'trainable'
Returns:

A list of values of each parameter.

Return type:

List[np.ndarray]

get_params(**tags)[source]

Get the list of parameters, filtered by the provided tags.

Parameters:
  • tags (dict) – Some common tags include ‘regularizable’ and
  • 'trainable'
get_params_internal(**tags)[source]

Get the list of parameters.

This internal method does not perform caching, and should be implemented by subclasses.

Returns:A list of trainable variables of type list(tf.Variable)
predict(xs)[source]

Predict ys based on input xs.

Parameters:xs (numpy.ndarray) – Input data.
Returns:The predicted ys.
set_param_values(flattened_params, name=None, **tags)[source]

Set the values for the parameters.

Parameters:
  • tags (dict) – Some common tags include ‘regularizable’ and
  • 'trainable'
class StochasticRegressor(input_shape, output_dim, name)[source]

Bases: garage.tf.regressors.base.Regressor

StochasticRegressor base class.

Parameters:
  • input_shape (tuple[int]) – Input shape.
  • output_dim (int) – Output dimension.
  • name (str) – Name of the regressor.
dist_info_sym(x_var, name=None)[source]

Symbolic graph of the distribution.

Parameters:
  • x_var (tf.Tensor) – Input tf.Tensor for the input data.
  • name (str) – Name of the new graph.
Returns:

tf.Tensor output of the symbolic distribution.

log_likelihood_sym(x_var, y_var, name=None)[source]

Symbolic graph of the log likelihood.

Parameters:
  • x_var (tf.Tensor) – Input tf.Tensor for the input data.
  • y_var (tf.Tensor) – Input tf.Tensor for the label of data.
  • name (str) – Name of the new graph.
Returns:

tf.Tensor output of the symbolic log likelihood.