DiSMEC++
dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction > Struct Template Reference

#include <dense_and_sparse.h>

Inheritance diagram for dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >:
dismec::objective::DenseAndSparseLinearBase dismec::objective::Objective dismec::stats::Tracked

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
 
BinaryLabelVectorget_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< StatisticsCollectionget_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 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 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

template<class MarginFunction, class SparseRegFunction, class DenseRegFunction>
struct dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >

Definition at line 164 of file dense_and_sparse.h.

Constructor & Destructor Documentation

◆ DenseAndSparseMargin()

template<class MarginFunction , class SparseRegFunction , class DenseRegFunction >
dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::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 
)
inline

Definition at line 165 of file dense_and_sparse.h.

Member Function Documentation

◆ calculate_2nd_derivative()

template<class MarginFunction , class SparseRegFunction , class DenseRegFunction >
void dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::calculate_2nd_derivative ( const DenseRealVector scores,
const BinaryLabelVector labels,
DenseRealVector out 
) const
inlineoverridevirtual

◆ calculate_derivative()

template<class MarginFunction , class SparseRegFunction , class DenseRegFunction >
void dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::calculate_derivative ( const DenseRealVector scores,
const BinaryLabelVector labels,
DenseRealVector out 
) const
inlineoverridevirtual

◆ calculate_loss()

template<class MarginFunction , class SparseRegFunction , class DenseRegFunction >
void dismec::objective::DenseAndSparseMargin< MarginFunction, SparseRegFunction, DenseRegFunction >::calculate_loss ( const DenseRealVector scores,
const BinaryLabelVector labels,
DenseRealVector out 
) const
inlineoverridevirtual

◆ regularization_gradient()

◆ regularization_gradient_at_zero()

◆ regularization_hessian()

◆ regularization_preconditioner()

◆ regularization_value()

Member Data Documentation

◆ DenseReg

◆ DenseRegStrength

◆ Phi

◆ SparseReg

◆ SparseRegStrength


The documentation for this struct was generated from the following file: