зеркало из https://github.com/mozilla/kaldi.git
trunk: fix to ApproxEqual in CuMatrix (unexpected behavior, different from Matrix, which caused test failures); test code refinements to stop spurious test failures; cosmetic fixes.
git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@3214 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
This commit is contained in:
Родитель
f8e0e3bd62
Коммит
a9d67d475c
|
@ -1239,7 +1239,7 @@ static void UnitTestCuApproxEqual() {
|
|||
Matrix<Real> diff(A), Bm(B);
|
||||
diff.AddMat(-1.0, Bm);
|
||||
Real norm = diff.FrobeniusNorm();
|
||||
KALDI_ASSERT( (norm <= tol) == (A.ApproxEqual(B, tol)));
|
||||
KALDI_ASSERT((norm <= tol * A.FrobeniusNorm()) == (A.ApproxEqual(B, tol)));
|
||||
tol *= 2.0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1374,7 +1374,7 @@ bool CuMatrixBase<Real>::ApproxEqual(const CuMatrixBase<Real> &other,
|
|||
float tol) const {
|
||||
CuMatrix<Real> diff(*this);
|
||||
diff.AddMat(-1.0, other);
|
||||
return (diff.FrobeniusNorm() <= tol);
|
||||
return (diff.FrobeniusNorm() <= tol * (*this).FrobeniusNorm());
|
||||
}
|
||||
|
||||
template<typename Real>
|
||||
|
|
|
@ -137,6 +137,7 @@ class CuMatrixBase {
|
|||
|
||||
bool IsUnit(Real tol = 0.001) const;
|
||||
|
||||
/// True if ((*this)-other).FrobeniusNorm() <= tol * this->FrobeniusNorm()
|
||||
bool ApproxEqual(const CuMatrixBase<Real> &other, float tol = 0.01) const;
|
||||
|
||||
/// Get size of matrix in bytes
|
||||
|
|
|
@ -72,12 +72,12 @@ template<typename Real> static void UnitTestCholesky() {
|
|||
// set dimension
|
||||
// computing the matrix for cholesky input
|
||||
// CuMatrix is cuda matrix class while Matrix is cpu matrix class
|
||||
CuMatrix<Real> A(dim,dim);
|
||||
Matrix<Real> B(dim,dim);
|
||||
CuMatrix<Real> A(dim, dim);
|
||||
Matrix<Real> B(dim, dim);
|
||||
Vector<Real> C(dim);
|
||||
for (MatrixIndexT i = 0; i < dim; i++) {
|
||||
B(i,i) = 1;
|
||||
C(i) = i + 1;
|
||||
B(i, i) = 1;
|
||||
C(i) = 1 + rand() % 4;
|
||||
}
|
||||
B.AddVecVec(1.0, C, C);
|
||||
// copy the matrix to cudamatrix object
|
||||
|
|
|
@ -63,11 +63,16 @@ struct HTransducerConfig {
|
|||
// Note-- this Register registers the easy-to-register options
|
||||
// but not the "sym_type" which is an enum and should be handled
|
||||
// separately in main().
|
||||
void Register (ParseOptions *po) {
|
||||
po->Register("transition-scale", &transition_scale, "Scale of transition probs (relative to LM)");
|
||||
po->Register("reverse", &reverse, "Set true to build time-reversed FST.");
|
||||
po->Register("push-weights", &push_weights, "Push weights (only applicable if reverse == true)");
|
||||
po->Register("push-delta", &push_delta, "Delta used in pushing weights (only applicable if reverse && push-weights");
|
||||
void Register (OptionsItf *po) {
|
||||
po->Register("transition-scale", &transition_scale,
|
||||
"Scale of transition probs (relative to LM)");
|
||||
po->Register("reverse", &reverse,
|
||||
"Set true to build time-reversed FST.");
|
||||
po->Register("push-weights", &push_weights,
|
||||
"Push weights (only applicable if reverse == true)");
|
||||
po->Register("push-delta", &push_delta,
|
||||
"Delta used in pushing weights (only applicable if "
|
||||
"reverse && push-weights");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче