本文整理汇总了C++中MatrixX::minCoeff方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixX::minCoeff方法的具体用法?C++ MatrixX::minCoeff怎么用?C++ MatrixX::minCoeff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixX
的用法示例。
在下文中一共展示了MatrixX::minCoeff方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: X
TYPED_TEST(TestMultinomialMaximizationStep, Maximization) {
// Build the corpus
std::mt19937 rng;
rng.seed(0);
MatrixXi X(100, 50);
VectorXi y(50);
std::uniform_int_distribution<> class_generator(0, 5);
std::exponential_distribution<> words_generator(0.1);
for (int d=0; d<50; d++) {
for (int w=0; w<100; w++) {
X(w, d) = static_cast<int>(words_generator(rng));
}
y(d) = class_generator(rng);
}
// Create the corpus and the model
auto corpus = std::make_shared<corpus::EigenClassificationCorpus>(X, y);
MatrixX<TypeParam> beta = MatrixX<TypeParam>::Random(10, 100);
beta.array() -= beta.minCoeff();
beta.array().rowwise() /= beta.array().colwise().sum();
auto model = std::make_shared<parameters::SupervisedModelParameters<TypeParam> >(
VectorX<TypeParam>::Constant(10, 0.1),
beta,
MatrixX<TypeParam>::Constant(10, 6, 1. / 6)
);
em::MultinomialSupervisedEStep<TypeParam> e_step(10, 1e-2, 2);
em::MultinomialSupervisedMStep<TypeParam> m_step(2);
for (size_t i=0; i<corpus->size(); i++) {
m_step.doc_m_step(
corpus->at(i),
e_step.doc_e_step(
corpus->at(i),
model
),
model
);
}
std::vector<TypeParam> progress;
m_step.get_event_dispatcher()->add_listener(
[&progress](std::shared_ptr<events::Event> event) {
if (event->id() == "MaximizationProgressEvent") {
auto prog_ev = std::static_pointer_cast<events::MaximizationProgressEvent<TypeParam> >(event);
progress.push_back(prog_ev->likelihood());
}
}
);
m_step.m_step(
model
);
ASSERT_EQ(1, progress.size());
ASSERT_GT(0, progress[0]);
}
开发者ID:angeloskath,项目名称:supervised-lda,代码行数:57,代码来源:test_multinomial_supervised_maximization_step.cpp