本文整理汇总了C++中Real::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Real::size方法的具体用法?C++ Real::size怎么用?C++ Real::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Real
的用法示例。
在下文中一共展示了Real::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
/** Viterbi search to find the best probable output sequence.
*/
vector<size_t> LinearChain::viterbi(Real &node, Real &edge, bool standard) {
/** Initializing.
*/
vector<vector<size_t> > psi;
vector<vector<long double> > delta;
size_t prev_max_j = defaultY_;
long double prev_maxj = -100000.0;
size_t i, j, k;
size_t m_example_size = node.size() / sizeY_;
/** Setting the omega.
*/
double omega;
if (option_.inferenceType_ == ZEROOUT)
omega = 1.0;
else if (option_.inferenceType_ == TP1 || option_.inferenceType_ == ZERO1)
omega = remainWeight_[0];
else
omega = 0.0;
if (standard)
omega = 0.0;
/** Recursion.
*/
for (i = 0; i < m_example_size-1; i++) {
vector<size_t> psi_i;
vector<long double> delta_i;
long double maxj = -10000.0;
size_t max_j = 0;
for (j = 0; j < sizeY_; j++) {
long double max = -10000.0;
size_t max_k = 0;
if (i == 0) {
max = 1.0; //m_M[MAT3(i,defaultY_,j)];
max_k = defaultY_;
} else {
vector<size_t>::iterator it, end_it;
if (option_.inferenceType_ == SFB) {
it = param_.activeSet2_[i-1].begin();
end_it = param_.activeSet2_[i-1].end();
} else {
it = param_.activeSet_[j].begin();
end_it = param_.activeSet_[j].end();
}
if (option_.inferenceType_ == TP2 || option_.inferenceType_ == ZERO2)
omega = remainWeight_[j];
if (standard) {
it = param_.allState_.begin();
end_it = param_.allState_.end();
omega = 0.0;
}
for ( ; it != end_it; ++it) {
double val = delta[i-1][*it] * edge[MAT2(*it,j)];
if (val > max) {
max = val;
max_k = *it;
}
}
// See [Siddiqi and Moore, 2005, ICML]
if (max < prev_maxj * omega) {
max = prev_maxj * omega;
max_k = prev_max_j;
}
} ///< for j
/**
*/
max = max * node[MAT2(i, j)]; // / m_AlphaScale[i];
delta_i.push_back(max);
psi_i.push_back(max_k);
if (max > maxj) {
maxj = max;
max_j = j;
}
} // for j
delta.push_back(delta_i);
psi.push_back(psi_i);
prev_max_j = max_j;
prev_maxj = maxj;
} // for i
/** Last state.
*/
vector<size_t> psi_i(sizeY_, 0);
vector<long double> delta_i(sizeY_, -10000.0);
long double max = -10000.0;
size_t max_k = 0;
for (size_t k=0; k < sizeY_; k++) {
double val = delta[m_example_size-2][k];
if (val > max) {
//.........这里部分代码省略.........