DiSMEC++
|
#include <dense_and_sparse.h>
Public Member Functions | |
DenseAndSparseMargin (std::shared_ptr< const GenericFeatureMatrix > dense_features, std::shared_ptr< const GenericFeatureMatrix > sparse_features, MarginFunction phi, DenseRegFunction dr, real_t drs, SparseRegFunction sr, real_t srs) | |
void | calculate_loss (const DenseRealVector &scores, const BinaryLabelVector &labels, DenseRealVector &out) const override |
void | calculate_derivative (const DenseRealVector &scores, const BinaryLabelVector &labels, DenseRealVector &out) const override |
void | calculate_2nd_derivative (const DenseRealVector &scores, const BinaryLabelVector &labels, DenseRealVector &out) const override |
real_t | regularization_value (const DenseRealVector &weights) const override |
void | regularization_gradient (const DenseRealVector &weights, Eigen::Ref< DenseRealVector > gradient) const override |
void | regularization_gradient_at_zero (Eigen::Ref< DenseRealVector > gradient) const override |
void | regularization_preconditioner (const DenseRealVector &weights, Eigen::Ref< DenseRealVector > pre_cond) const override |
void | regularization_hessian (const DenseRealVector &weights, const DenseRealVector &direction, Eigen::Ref< DenseRealVector > target) const override |
Public Member Functions inherited from dismec::objective::DenseAndSparseLinearBase | |
DenseAndSparseLinearBase (std::shared_ptr< const GenericFeatureMatrix > dense_features, std::shared_ptr< const GenericFeatureMatrix > sparse_features) | |
long | num_instances () const noexcept |
long | num_variables () const noexcept override |
BinaryLabelVector & | get_label_ref () |
void | update_costs (real_t positive, real_t negative) |
void | update_features (const DenseFeatures &dense, const SparseFeatures &sparse) |
Public Member Functions inherited from dismec::objective::Objective | |
Objective () | |
virtual | ~Objective () noexcept=default |
real_t | value (const HashVector &location) |
Evaluate the objective at the given location . More... | |
void | diag_preconditioner (const HashVector &location, Eigen::Ref< DenseRealVector > target) |
Get precondition to be used in CG optimization. More... | |
void | project_to_line (const HashVector &location, const DenseRealVector &direction) |
creates a function g such that g(a) = objective(location + a * direction) Use lookup_on_line() to evaluate g . More... | |
void | gradient_at_zero (Eigen::Ref< DenseRealVector > target) |
Gets the gradient for location zero. More... | |
void | gradient (const HashVector &location, Eigen::Ref< DenseRealVector > target) |
Evaluate the gradient at location . More... | |
void | hessian_times_direction (const HashVector &location, const DenseRealVector &direction, Eigen::Ref< DenseRealVector > target) |
Calculates the product of the Hessian matrix at location with direction . More... | |
void | gradient_and_pre_conditioner (const HashVector &location, Eigen::Ref< DenseRealVector > gradient, Eigen::Ref< DenseRealVector > pre) |
Combines the calculation of gradient and pre-conditioner, which may be more efficient in some cases. More... | |
Public Member Functions inherited from dismec::stats::Tracked | |
Tracked () | |
Default constructor, creates the internal stats::StatisticsCollection . More... | |
void | register_stat (const std::string &name, std::unique_ptr< Statistics > stat) |
Registers a tracker for the statistics name . More... | |
std::shared_ptr< StatisticsCollection > | get_stats () const |
Gets an ownership-sharing reference to the StatisticsCollection . More... | |
Public Attributes | |
MarginFunction | Phi |
real_t | DenseRegStrength |
DenseRegFunction | DenseReg |
real_t | SparseRegStrength |
SparseRegFunction | SparseReg |
Additional Inherited Members | |
Protected Member Functions inherited from dismec::objective::DenseAndSparseLinearBase | |
long | get_num_variables () const noexcept |
actual implementation of num_variables() . We need this non-virtual function to be called during the constructor More... | |
const DenseRealVector & | x_times_w (const HashVector &w) |
Calculates the vector of feature matrix times weights w More... | |
template<class Derived > | |
void | update_xtw_cache (const HashVector &new_weight, const Eigen::MatrixBase< Derived > &new_result) |
Updates the cached value for x_times_w. More... | |
void | project_linear_to_line (const HashVector &location, const DenseRealVector &direction) |
Prepares the cache variables for line projection. More... | |
auto | line_interpolation (real_t t) const |
void | declare_vector_on_last_line (const HashVector &location, real_t t) override |
State that the given vector corresponds to a certain position on the line of the last line search. More... | |
const DenseFeatures & | dense_features () const |
const SparseFeatures & | sparse_features () const |
const DenseRealVector & | costs () const |
const BinaryLabelVector & | labels () const |
Protected Member Functions inherited from dismec::stats::Tracked | |
~Tracked () | |
Non-virtual destructor. Declared protected, so we don't accidentally try to do a polymorphic delete. More... | |
template<class T > | |
void | record (stat_id_t stat, T &&value) |
Record statistics. This function just forwards all its arguments to the internal StatisticsCollection . More... | |
void | declare_stat (stat_id_t index, StatisticMetaData meta) |
Declares a new statistics. This function just forwards all its arguments to the internal StatisticsCollection . More... | |
void | declare_tag (tag_id_t index, std::string name) |
Declares a new tag. This function just forwards all its arguments to the internal StatisticsCollection . More... | |
template<class... Args> | |
void | set_tag (tag_id_t tag, long value) |
Set value of tag. This function just forwards all its arguments to the internal StatisticsCollection . More... | |
template<class... Args> | |
auto | make_timer (stat_id_t id, Args... args) |
Creates a new ScopeTimer using stats::record_scope_time . More... | |
Definition at line 164 of file dense_and_sparse.h.
|
inline |
Definition at line 165 of file dense_and_sparse.h.
|
inlineoverridevirtual |
Implements dismec::objective::DenseAndSparseLinearBase.
Definition at line 195 of file dense_and_sparse.h.
References dismec::objective::DenseAndSparseLinearBase::labels(), and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::Phi.
|
inlineoverridevirtual |
Implements dismec::objective::DenseAndSparseLinearBase.
Definition at line 184 of file dense_and_sparse.h.
References dismec::objective::DenseAndSparseLinearBase::labels(), and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::Phi.
|
inlineoverridevirtual |
Implements dismec::objective::DenseAndSparseLinearBase.
Definition at line 174 of file dense_and_sparse.h.
References dismec::objective::DenseAndSparseLinearBase::labels(), and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::Phi.
|
inlineoverridevirtual |
Implements dismec::objective::DenseAndSparseLinearBase.
Definition at line 219 of file dense_and_sparse.h.
References dismec::objective::DenseAndSparseLinearBase::dense_features(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseReg, dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseRegStrength, dismec::objective::Objective::gradient(), dismec::objective::DenseAndSparseLinearBase::sparse_features(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseReg, and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseRegStrength.
|
inlineoverridevirtual |
Implements dismec::objective::DenseAndSparseLinearBase.
Definition at line 232 of file dense_and_sparse.h.
References dismec::objective::DenseAndSparseLinearBase::dense_features(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseReg, dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseRegStrength, dismec::objective::Objective::gradient(), dismec::objective::DenseAndSparseLinearBase::sparse_features(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseReg, and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseRegStrength.
|
inlineoverridevirtual |
Implements dismec::objective::DenseAndSparseLinearBase.
Definition at line 260 of file dense_and_sparse.h.
References dismec::objective::DenseAndSparseLinearBase::dense_features(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseReg, dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseRegStrength, dismec::objective::DenseAndSparseLinearBase::sparse_features(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseReg, and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseRegStrength.
|
inlineoverridevirtual |
Implements dismec::objective::DenseAndSparseLinearBase.
Definition at line 247 of file dense_and_sparse.h.
References dismec::objective::DenseAndSparseLinearBase::dense_features(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseReg, dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseRegStrength, dismec::objective::DenseAndSparseLinearBase::sparse_features(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseReg, and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseRegStrength.
|
inlineoverridevirtual |
Implements dismec::objective::DenseAndSparseLinearBase.
Definition at line 205 of file dense_and_sparse.h.
References dismec::objective::DenseAndSparseLinearBase::dense_features(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseReg, dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseRegStrength, dismec::objective::DenseAndSparseLinearBase::sparse_features(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseReg, and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseRegStrength.
DenseRegFunction dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseReg |
Definition at line 275 of file dense_and_sparse.h.
Referenced by dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_gradient(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_gradient_at_zero(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_hessian(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_preconditioner(), and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_value().
real_t dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::DenseRegStrength |
Definition at line 274 of file dense_and_sparse.h.
Referenced by dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_gradient(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_gradient_at_zero(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_hessian(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_preconditioner(), and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_value().
MarginFunction dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::Phi |
Definition at line 273 of file dense_and_sparse.h.
Referenced by dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::calculate_2nd_derivative(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::calculate_derivative(), and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::calculate_loss().
SparseRegFunction dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseReg |
Definition at line 277 of file dense_and_sparse.h.
Referenced by dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_gradient(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_gradient_at_zero(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_hessian(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_preconditioner(), and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_value().
real_t dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::SparseRegStrength |
Definition at line 276 of file dense_and_sparse.h.
Referenced by dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_gradient(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_gradient_at_zero(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_hessian(), dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_preconditioner(), and dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::regularization_value().