6 #ifndef DISMEC_SUBMODEL_H
7 #define DISMEC_SUBMODEL_H
14 using model_t = std::remove_reference_t<decltype(*std::declval<T>())>;
15 static_assert(std::is_convertible_v<std::remove_cv_t<model_t>&,
Model&>,
"T should be like a pointer to Model");
31 if constexpr (std::is_const_v<model_t>) {
32 throw std::logic_error(
"Cannot set weights for constant sub-model");
39 throw std::logic_error(
"Cannot predict from model view");
Strong typedef for an int to signify a label id.
A model combines a set of weight with some meta-information about these weights.
long num_labels() const noexcept
How many labels are in the underlying dataset.
Eigen::Ref< PredictionMatrix > PredictionMatrixOut
label_id_t labels_begin() const noexcept
void get_weights_for_label_unchecked(label_id_t label, Eigen::Ref< DenseRealVector > target) const override
Unchecked version of get_weights_for_label().
bool has_sparse_weights() const override
whether this model stores the weights in a sparse format, or a dense format.
void predict_scores_unchecked(const GenericInMatrix &instances, PredictionMatrixOut target) const override
Unchecked version of predict_scores().
SubModelWrapper(T original, label_id_t begin, label_id_t end)
std::remove_reference_t< decltype(*std::declval< T >())> model_t
void set_weights_for_label_unchecked(label_id_t label, const GenericInVector &weights) override
Unchecked version of set_weights_for_label().
long num_features() const override
How many weights are in each weight vector, i.e. how many features should the input have.
constexpr T to_index() const
! Explicitly convert to an integer.
Specifies how to interpret a weight matrix for a partial model.