DiSMEC++
dismec::objective::Regularized_SquaredHingeSVC Class Reference

#include <reg_sq_hinge.h>

Inheritance diagram for dismec::objective::Regularized_SquaredHingeSVC:
dismec::objective::LinearClassifierImpBase< Regularized_SquaredHingeSVC > dismec::objective::LinearClassifierBase dismec::objective::Objective dismec::stats::Tracked

Public Member Functions

 Regularized_SquaredHingeSVC (std::shared_ptr< const GenericFeatureMatrix > X, std::unique_ptr< Objective > regularizer)
 
const features_tfeatures () const
 
void gradient_imp (const HashVector &location, Eigen::Ref< DenseRealVector > target)
 
void gradient_at_zero_imp (Eigen::Ref< DenseRealVector > target)
 
void hessian_times_direction_imp (const HashVector &location, const DenseRealVector &direction, Eigen::Ref< DenseRealVector > target)
 
void diag_preconditioner_imp (const HashVector &location, Eigen::Ref< DenseRealVector > target)
 
void gradient_and_pre_conditioner_imp (const HashVector &location, Eigen::Ref< DenseRealVector > gradient, Eigen::Ref< DenseRealVector > pre)
 
- Public Member Functions inherited from dismec::objective::LinearClassifierImpBase< Regularized_SquaredHingeSVC >
 LinearClassifierImpBase (std::shared_ptr< const GenericFeatureMatrix > X, std::unique_ptr< Objective > regularizer)
 
- Public Member Functions inherited from dismec::objective::LinearClassifierBase
 LinearClassifierBase (std::shared_ptr< const GenericFeatureMatrix > X)
 
long num_instances () const noexcept
 
long num_variables () const noexcept override
 
BinaryLabelVectorget_label_ref ()
 
void update_costs (real_t positive, real_t negative)
 
- 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< StatisticsCollectionget_stats () const
 Gets an ownership-sharing reference to the StatisticsCollection. More...
 

Static Public Member Functions

template<typename OtherDerived >
static real_t value_from_xTw (const DenseRealVector &cost, const BinaryLabelVector &labels, const Eigen::DenseBase< OtherDerived > &xTw)
 

Private Types

using features_t = SparseFeatures
 

Private Member Functions

void invalidate_labels () override
 
void margin_error (const HashVector &w)
 
template<class T , class U >
void gradient_and_pre_conditioner_tpl (const HashVector &location, T &&gradient, U &&pre)
 

Private Attributes

VectorHash m_Last_MV
 
std::vector< int > m_MVPos
 
std::vector< real_tm_MVVal
 

Additional Inherited Members

- Protected Member Functions inherited from dismec::objective::LinearClassifierImpBase< Regularized_SquaredHingeSVC >
const Regularized_SquaredHingeSVCderived () const
 
Regularized_SquaredHingeSVCderived ()
 
real_t value_unchecked (const HashVector &location) override
 
real_t lookup_on_line (real_t position) override
 Looks up the value of the objective on the line defined by the last call to project_to_line(). More...
 
void project_to_line_unchecked (const HashVector &location, const DenseRealVector &direction) override
 
void gradient_unchecked (const HashVector &location, Eigen::Ref< DenseRealVector > target) override
 
void gradient_at_zero_unchecked (Eigen::Ref< DenseRealVector > target) override
 
void hessian_times_direction_unchecked (const HashVector &location, const DenseRealVector &direction, Eigen::Ref< DenseRealVector > target) override
 
void diag_preconditioner_unchecked (const HashVector &location, Eigen::Ref< DenseRealVector > target) override
 
void gradient_and_pre_conditioner_unchecked (const HashVector &location, Eigen::Ref< DenseRealVector > gradient, Eigen::Ref< DenseRealVector > pre) override
 
- Protected Member Functions inherited from dismec::objective::LinearClassifierBase
const DenseRealVectorx_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 GenericFeatureMatrixgeneric_features () const
 
const DenseFeaturesdense_features () const
 
const SparseFeaturessparse_features () const
 
const DenseRealVectorcosts () const
 
const BinaryLabelVectorlabels () 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...
 

Detailed Description

Objective for regularized Support Vector classification with Squared Hinge loss. This is for binary labels, multilabel problems can be generated trivially by having l independent Regularized_SquaredHingeSVC objectives.

Definition at line 21 of file reg_sq_hinge.h.

Member Typedef Documentation

◆ features_t

Constructor & Destructor Documentation

◆ Regularized_SquaredHingeSVC()

Regularized_SquaredHingeSVC::Regularized_SquaredHingeSVC ( std::shared_ptr< const GenericFeatureMatrix X,
std::unique_ptr< Objective regularizer 
)
explicit

Member Function Documentation

◆ diag_preconditioner_imp()

void Regularized_SquaredHingeSVC::diag_preconditioner_imp ( const HashVector location,
Eigen::Ref< DenseRealVector target 
)

Definition at line 46 of file reg_sq_hinge.cpp.

References gradient_and_pre_conditioner_tpl().

◆ features()

◆ gradient_and_pre_conditioner_imp()

void Regularized_SquaredHingeSVC::gradient_and_pre_conditioner_imp ( const HashVector location,
Eigen::Ref< DenseRealVector gradient,
Eigen::Ref< DenseRealVector pre 
)

◆ gradient_and_pre_conditioner_tpl()

◆ gradient_at_zero_imp()

void Regularized_SquaredHingeSVC::gradient_at_zero_imp ( Eigen::Ref< DenseRealVector target)

◆ gradient_imp()

void Regularized_SquaredHingeSVC::gradient_imp ( const HashVector location,
Eigen::Ref< DenseRealVector target 
)

Definition at line 35 of file reg_sq_hinge.cpp.

References gradient_and_pre_conditioner_tpl().

◆ hessian_times_direction_imp()

void Regularized_SquaredHingeSVC::hessian_times_direction_imp ( const HashVector location,
const DenseRealVector direction,
Eigen::Ref< DenseRealVector target 
)

◆ invalidate_labels()

void Regularized_SquaredHingeSVC::invalidate_labels ( )
overrideprivatevirtual

This function will be called whenever m_Y changes so that derived classes can invalidate their caches.

Implements dismec::objective::LinearClassifierBase.

Definition at line 112 of file reg_sq_hinge.cpp.

References m_Last_MV.

◆ margin_error()

◆ value_from_xTw()

template<typename OtherDerived >
static real_t dismec::objective::Regularized_SquaredHingeSVC::value_from_xTw ( const DenseRealVector cost,
const BinaryLabelVector labels,
const Eigen::DenseBase< OtherDerived > &  xTw 
)
inlinestatic

Definition at line 41 of file reg_sq_hinge.h.

References dismec::objective::LinearClassifierBase::labels().

Member Data Documentation

◆ m_Last_MV

VectorHash dismec::objective::Regularized_SquaredHingeSVC::m_Last_MV
private

Definition at line 58 of file reg_sq_hinge.h.

Referenced by invalidate_labels(), and margin_error().

◆ m_MVPos

std::vector<int> dismec::objective::Regularized_SquaredHingeSVC::m_MVPos
private

◆ m_MVVal

std::vector<real_t> dismec::objective::Regularized_SquaredHingeSVC::m_MVVal
private

Definition at line 61 of file reg_sq_hinge.h.

Referenced by gradient_and_pre_conditioner_tpl(), and margin_error().


The documentation for this class was generated from the following files: