27 n_xs =
Rand() % 200 + 100,
28 n_labels =
Rand() % 20 + 10;
39 std::vector<int32> classes;
59 log_posteriors.
Row(
i).CopyFromVec(log_post);
63 float tolerance = 0.01;
70 n_xs =
Rand() % 200 + 100,
71 n_labels =
Rand() % 20 + 10;
72 double normalizer = 0.01;
76 std::vector<int32> ys;
78 ys.push_back(
Rand() % n_labels);
86 classifier.
Train(xs, ys, conf);
92 xs_with_prior(
i, n_features) = 1.0;
105 ys, xw, &grad, normalizer);
118 xw_rand, &grad, normalizer);
125 using namespace kaldi;
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void ApplyExp()
Apply exponential to each value in vector.
BaseFloat GetObjfAndGrad(const Matrix< BaseFloat > &xs, const std::vector< int32 > &ys, const Matrix< BaseFloat > &xw, Matrix< BaseFloat > *grad, BaseFloat normalizer)
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
bool ApproxEqual(const MatrixBase< Real > &other, float tol=0.01) const
Returns true if ((*this)-other).FrobeniusNorm() <= tol * (*this).FrobeniusNorm(). ...
void Train(const Matrix< BaseFloat > &xs, const std::vector< int32 > &ys, const LogisticRegressionConfig &conf)
void CopyFromMat(const MatrixBase< OtherReal > &M, MatrixTransposeType trans=kNoTrans)
Copy given matrix. (no resize is done).
void CopyRowFromMat(const MatrixBase< Real > &M, MatrixIndexT row)
Extracts a row of the matrix M.
void GetLogPosteriors(const Matrix< BaseFloat > &xs, Matrix< BaseFloat > *log_posteriors)
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
void SetRandn()
Sets to random values of a normal distribution.
void AddMatMat(const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const MatrixBase< Real > &B, MatrixTransposeType transB, const Real beta)
int Rand(struct RandomState *state)
Real Sum() const
Returns sum of the elements.
A class representing a vector.
void SetWeights(const Matrix< BaseFloat > &weights, const std::vector< int32 > classes)
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Matrix< BaseFloat > weights_
void UnitTestPosteriors()
Sub-matrix representation.
static bool ApproxEqual(float a, float b, float relative_tolerance=0.001)
return abs(a - b) <= relative_tolerance * (abs(a)+abs(b)).