Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
/* How observable parameters can be registered*/
// Register standard parameters
SG_ADD(&m_w, "weights", "Model weigths", ParameterProperties::MODEL);
// Version A: Register observable parameters. The user could then get a list
// (vector) of the parameters he can observe inside this model. Only the parameters
// registered with this method can be observed through observe().
register_observable_param("run_weigths", "Model weights during training");
// Version B: Register observable parameters using SG_ADD. This would require
// to add a member variable for each observable value we will emit.
SG_ADD(&m_obs_weights, "run_weights", "Model weights during training", ParameterProperties::OBSERVABLE);
void MyFabulousMachine::train()
/* Train method Code */
// Version A: This will lead to an error if the specified name was not registered before
// using the register_observale_param method.
observe("run_weights", step, make_any(variable_containing_the_weights));
// Version B: If the parameter has as property OBSERVABLE, then it will be emitted through the
// observe() method inside put. This will also unify the observable framework with the put one
// (which may make things a bit unclear).
put("run_weights", &m_obs_weigths)
/* Other train method code */
// Version A: The "new" observe method.
void observe(string name, int step, Any value)
if (!m_observable_parameters.contains(name))
this->_observe(ObservedValue::make_observation(name, step, value));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.