garage.tf.regressors.bernoulli_mlp_regressor module¶
Bernoulli MLP Regressor based on MLP with Normalized Inputs.
-
class
BernoulliMLPRegressor
(input_shape, output_dim, name='BernoulliMLPRegressor', hidden_sizes=(32, 32), hidden_nonlinearity=<function relu>, hidden_w_init=<tensorflow.python.ops.init_ops.GlorotUniform object>, hidden_b_init=<tensorflow.python.ops.init_ops.Zeros object>, output_nonlinearity=<function sigmoid>, output_w_init=<tensorflow.python.ops.init_ops.GlorotUniform object>, output_b_init=<tensorflow.python.ops.init_ops.Zeros object>, optimizer=None, optimizer_args=None, tr_optimizer=None, tr_optimizer_args=None, use_trust_region=True, max_kl_step=0.01, normalize_inputs=True, layer_normalization=False)[source]¶ Bases:
garage.tf.regressors.base.StochasticRegressor
Fits data to a Bernoulli distribution, parameterized by an MLP.
Parameters: - input_shape (tuple[int]) – Input shape of the training data. Since an MLP model is used, implementation assumes flattened inputs. The input shape of each data point should thus be of shape (x, ).
- output_dim (int) – Output dimension of the model.
- name (str) – Model name, also the variable scope.
- hidden_sizes (list[int]) – Output dimension of dense layer(s) for the MLP for the network. For example, (32, 32) means the MLP consists of two hidden layers, each with 32 hidden units.
- hidden_nonlinearity (Callable) – Activation function for intermediate dense layer(s). It should return a tf.Tensor. Set it to None to maintain a linear activation.
- hidden_w_init (Callable) – Initializer function for the weight of intermediate dense layer(s). The function should return a tf.Tensor. Default is Glorot uniform initializer.
- hidden_b_init (Callable) – Initializer function for the bias of intermediate dense layer(s). The function should return a tf.Tensor. Default is zero initializer.
- output_nonlinearity (Callable) – Activation function for output dense layer. It should return a tf.Tensor. Set it to None to maintain a linear activation.
- output_w_init (Callable) – Initializer function for the weight of output dense layer(s). The function should return a tf.Tensor. Default is Glorot uniform initializer.
- output_b_init (Callable) – Initializer function for the bias of output dense layer(s). The function should return a tf.Tensor. Default is zero initializer.
- optimizer (garage.tf.Optimizer) – Optimizer for minimizing the negative log-likelihood. Defaults to LbsgsOptimizer
- optimizer_args (dict) – Arguments for the optimizer. Default is None, which means no arguments.
- tr_optimizer (garage.tf.Optimizer) – Optimizer for trust region approximation. Defaults to ConjugateGradientOptimizer.
- tr_optimizer_args (dict) – Arguments for the trust region optimizer. Default is None, which means no arguments.
- use_trust_region (bool) – Whether to use trust region constraint.
- max_kl_step (float) – KL divergence constraint for each iteration.
- normalize_inputs (bool) – Bool for normalizing inputs or not.
- layer_normalization (bool) – Bool for using layer normalization or not.
-
dist_info_sym
(x_var, name=None)[source]¶ Build a symbolic graph of the distribution parameters.
Parameters: - x_var (tf.Tensor) – Input tf.Tensor for the input data.
- name (str) – Name of the new graph.
Returns: - Output of the symbolic graph of the distribution
parameters.
Return type: dict[tf.Tensor]
-
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.
-
get_params_internal
(**args)[source]¶ Get the params, which are the trainable variables.
Parameters: args – Ignored by the function. Will be removed in future release. Returns: A list of trainable variables in the current variable scope. Return type: List[tf.Variable]
-
log_likelihood_sym
(x_var, y_var, name=None)[source]¶ Build a 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 one hot label of data.
- name (str) – Name of the new graph.
Returns: Output of the symbolic log-likelihood graph.
Return type: tf.Tensor
-
predict
(xs)[source]¶ Predict ys based on input xs.
Parameters: xs (numpy.ndarray) – Input data of shape (samples, input_dim) Returns: - The deterministic predicted ys (one hot vectors)
- of shape (samples, output_dim)
Return type: numpy.ndarray