Turi Create
4.0
|
#include <toolkits/factorization/factorization_model_sgd_interface.hpp>
Public Member Functions | |
void | setup (const v2::ml_data &train_data, const std::map< std::string, flexible_type > &options) |
double | l2_regularization_factor () const |
double | max_step_size () const |
void | setup_iteration (size_t iteration, double step_size) |
void | finalize_iteration () |
bool | state_is_numerically_stable () const GL_HOT_INLINE_FLATTEN |
void | setup_optimization (size_t random_seed=size_t(-1), bool trial_mode=false) |
double | current_regularization_penalty () const |
double | calculate_loss (const v2::ml_data &data) const |
double | reported_loss_value (double accumulative_loss) const |
std::string | reported_loss_name () const |
double | calculate_fx (size_t thread_idx, const std::vector< v2::ml_data_entry > &x) const GL_HOT_FLATTEN |
GL_HOT_INLINE_FLATTEN double | apply_sgd_step (size_t thread_idx, const std::vector< v2::ml_data_entry > &x, double y, double step_size, bool apply_regularization) |
GL_HOT_INLINE_FLATTEN double | apply_sgd_step (size_t thread_idx, const std::vector< v2::ml_data_entry > &x, double y, double step_size) |
double | apply_pairwise_sgd_step (size_t thread_idx, const std::vector< v2::ml_data_entry > &x_positive, const std::vector< v2::ml_data_entry > &x_negative, double step_size) GL_HOT_FLATTEN |
Public Attributes | |
bool | currently_in_trial_mode = false |
Static Public Attributes | |
static constexpr model_regularization_type | regularization_type = _regularization_type |
This class provides the interface layer for the basic sgd solver, this time for the second_order model. It provides functions to calculate the gradient and apply a gradient update. (In the original design, these were just folded into the model; they are now seperated out to make the original model simpler.)
For documentation on the interface requirements of each of the solvers, see the sgd algorithms; each one requires specific interface functions to be defined.
Definition at line 54 of file factorization_model_sgd_interface.hpp.
|
inline |
Calculate the gradient with respect to a single observation, then applies it. Used by the basic sgd solver; this one is used for the first order model.
x is the observation vector, in standard ml_data_entry format, formed by ml_data_iterator.fill_observation(...).
struct ml_data_entry { size_t column_index; // Column id size_t index; // Local index within the column. double value; // Value };
Definition at line 1505 of file factorization_model_sgd_interface.hpp.
|
inline |
Calculate the gradient with respect to a single observation, then applies it. Used by the basic sgd solver; this one is used for the second_order model.
x is the observation vector, in standard ml_data_entry format, formed by ml_data_iterator.fill_observation(...).
struct ml_data_entry { size_t column_index; // Column id size_t index; // Local index within the column. double value; // Value };
Definition at line 1335 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
Calculate the gradient with respect to a single observation, then applies it. Used by the basic sgd solver; this one is used for the second_order model.
x is the observation vector, in standard ml_data_entry format, formed by ml_data_iterator.fill_observation(...).
struct ml_data_entry { size_t column_index; // Column id size_t index; // Local index within the column. double value; // Value };
Implements turi::sgd::sgd_interface_base.
Definition at line 1483 of file factorization_model_sgd_interface.hpp.
|
inline |
Calculate the gradient with respect to a single observation, then applies it. Used by the basic sgd solver; this one is used for the second_order model.
x is the observation vector, in standard ml_data_entry format, formed by ml_data_iterator.fill_observation(...).
struct ml_data_entry { size_t column_index; // Column id size_t index; // Local index within the column. double value; // Value };
Definition at line 1288 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
Calculate the value of the objective function as determined by the loss function, for a full data set, minus the regularization penalty.
Implements turi::sgd::sgd_interface_base.
Definition at line 693 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
Calculate the current regularization penalty.
Implements turi::sgd::sgd_interface_base.
Definition at line 622 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
Finalizes the iteration. Called after each pass through the data.
Reimplemented from turi::sgd::sgd_interface_base.
Definition at line 510 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
Returns the l2 regularization coefficient.
Reimplemented from turi::sgd::sgd_interface_base.
Definition at line 376 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
Returns an upper bound on the sgd step size.
Reimplemented from turi::sgd::sgd_interface_base.
Definition at line 385 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
The name of the loss to report on each iteration.
For example, if squared error loss is used, reported_loss_name() could give RMSE, and then reported_loss_value(v) would be std::sqrt(v).
Implements turi::sgd::sgd_interface_base.
Definition at line 754 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
The value of the reported loss. The apply_sgd_step accumulates estimated loss values between samples. This function is called with this accumulated value to get a value
For example, if squared error loss is used, reported_loss_name() could give RMSE, and then reported_loss_value(v) would be std::sqrt(v).
Implements turi::sgd::sgd_interface_base.
Definition at line 744 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
Set up all the stuff needed for processing the data at each iteration.
Reimplemented from turi::sgd::sgd_interface_base.
Definition at line 268 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
Set up the class and constants before every iteration.
Reimplemented from turi::sgd::sgd_interface_base.
Definition at line 403 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
Sets up the optimization run. Called at the beginning of an optimization run or to reset the state.
Implements turi::sgd::sgd_interface_base.
Definition at line 602 of file factorization_model_sgd_interface.hpp.
|
inlinevirtual |
Test whether the current state is numerically stable or not; if not, it needs to be reset.
Reimplemented from turi::sgd::sgd_interface_base.
Definition at line 580 of file factorization_model_sgd_interface.hpp.
bool turi::factorization::factorization_sgd_interface< GLMModel, _LossModelProfile, _regularization_type >::currently_in_trial_mode = false |
Trial mode is used to find the sgd step size.
Definition at line 88 of file factorization_model_sgd_interface.hpp.
|
static |
The model_regularization_type.
Definition at line 92 of file factorization_model_sgd_interface.hpp.