8 DIAGNOSTIC_IGNORE_GCC(
"-Wmaybe-uninitialized")
24 auto test_mat = std::make_shared<DenseModel::WeightMatrix>(DenseModel::WeightMatrix::Zero(4, 3));
28 CHECK_THROWS(model.get_weights_for_label(
label_id_t{0}, target));
31 target = DenseRealVector::Ones(4);
32 REQUIRE_NOTHROW(model.get_weights_for_label(
label_id_t{0}, target));
35 CHECK_THROWS(model.get_weights_for_label(
label_id_t{-1}, target));
36 CHECK_THROWS(model.get_weights_for_label(
label_id_t{3}, target));
44 auto test_mat = std::make_shared<DenseModel::WeightMatrix>(DenseModel::WeightMatrix::Zero(4, 3));
51 source = DenseRealVector::Ones(4);
62 auto test_mat = std::make_shared<DenseModel::WeightMatrix>(DenseModel::WeightMatrix::Zero(4, 3));
66 source.coeffRef(2) = 2.0;
70 model.get_weights_for_label(
label_id_t{1}, target);
72 for(
int i = 0; i < 4; ++i) {
73 CHECK(source[i] == target[i]);
103 CHECK(partial.is_partial_model());
104 CHECK(partial.labels_begin() ==
label_id_t{1});
106 CHECK(partial.num_labels() == 5);
107 CHECK(partial.num_weights() == 3);
114 auto build = [](
long first_label,
long label_count,
long total_labels) {
118 SUBCASE(
"invalid range") {
119 CHECK_THROWS(build(4, 3, 5));
120 CHECK_THROWS(build(1, 5, 5));
124 SUBCASE(
"non positive") {
126 CHECK_THROWS(build(-1, 5, 5));
127 CHECK_THROWS(build(3, 0, 5));
128 CHECK_THROWS(build(3, -1, 5));
129 CHECK_THROWS(build(3, 2, 0));
130 CHECK_THROWS(build(3, 2, -1));
136 SUBCASE(
"data mismatch") {
137 auto matrix = std::make_shared<DenseModel::WeightMatrix>(4, 3);
Strong typedef for an int to signify a label id.
Implementation of the Model class that stores the weights as a single, dense matrix.
label_id_t labels_end() const noexcept
long num_labels() const noexcept
How many labels are in the underlying dataset.
bool is_partial_model() const
returns true if this instance only stores part of the weights of an entire model
long num_weights() const noexcept
How many weights vectors are in this model.
GenericInVector WeightVectorIn
label_id_t labels_begin() const noexcept
Eigen::Ref< DenseColMajor< T > > DenseColMajorRef
Eigen::Ref< DenseRowMajor< T > > DenseRowMajorRef
TEST_CASE("get dense weights errors")
Main namespace in which all types, classes, and functions are defined.
types::DenseVector< real_t > DenseRealVector
Any dense, real values vector.
types::DenseRowMajor< real_t > PredictionMatrix
Dense matrix in Row Major format used for predictions.
Specifies how to interpret a weight matrix for a partial model.