6 #ifndef DISMEC_INITIALIZER_H
7 #define DISMEC_INITIALIZER_H
64 [[nodiscard]]
virtual std::unique_ptr<WeightsInitializer>
65 make_initializer(
const std::shared_ptr<const GenericFeatureMatrix>& features)
const = 0;
81 std::optional<std::filesystem::path> biases);
Base class for all weight init strategies.
virtual ~WeightInitializationStrategy()=default
virtual std::unique_ptr< WeightsInitializer > make_initializer(const std::shared_ptr< const GenericFeatureMatrix > &features) const =0
Creats a new, thread local WeightsInitializer.
Base class for all weight initializers.
virtual ~WeightsInitializer()=default
virtual void get_initial_weight(label_id_t label_id, Eigen::Ref< DenseRealVector > target, objective::Objective &objective)=0
Generate an initial vector for the given label. The result should be placed in target.
Strong typedef for an int to signify a label id.
Class that models an optimization objective.
A base class to be used for all types that implement some for of statistics tracking.
std::shared_ptr< WeightInitializationStrategy > create_zero_initializer()
Creates an initialization strategy that initializes all weight vectors to zero.
std::shared_ptr< WeightInitializationStrategy > create_pretrained_initializer(std::shared_ptr< model::Model > model)
Creates an initialization strategy that uses an already trained model to set the initial weights.
std::shared_ptr< WeightInitializationStrategy > create_feature_mean_initializer(std::shared_ptr< DatasetBase > data, real_t pos=1, real_t neg=-2)
Creates an initialization strategy based on the mean of positive and negative features.
std::shared_ptr< WeightInitializationStrategy > create_multi_pos_mean_strategy(std::shared_ptr< DatasetBase > data, int max_pos, real_t pos=1, real_t neg=-2)
Creates an initialization strategy based on the mean of positive and negative features.
std::shared_ptr< WeightInitializationStrategy > create_constant_initializer(DenseRealVector vec)
std::shared_ptr< WeightInitializationStrategy > create_ova_primal_initializer(const std::shared_ptr< DatasetBase > &data, RegularizerSpec regularizer, LossType loss)
std::shared_ptr< WeightInitializationStrategy > create_numpy_initializer(const std::filesystem::path &weights, std::optional< std::filesystem::path > biases)
Creates an initialization strategy that uses weights loaded from a npy file.
std::variant< objective::SquaredNormConfig, objective::HuberConfig, objective::ElasticConfig > RegularizerSpec
types::DenseVector< real_t > DenseRealVector
Any dense, real values vector.
float real_t
The default type for floating point values.