37     using namespace kaldi;
    40         "Copy matrices, or archives of matrices (e.g. features or transforms)\n"    41         "Also see copy-feats which has other format options\n"    43         "Usage: copy-matrix [options] <matrix-in-rspecifier> <matrix-out-wspecifier>\n"    44         "  or: copy-matrix [options] <matrix-in-rxfilename> <matrix-out-wxfilename>\n"    45         " e.g.: copy-matrix --binary=false 1.mat -\n"    46         "   copy-matrix ark:2.trans ark,t:-\n"    47         "See also: copy-feats, matrix-sum\n";
    50     bool apply_log = 
false;
    51     bool apply_exp = 
false;
    52     bool apply_softmax_per_row = 
false;
    58     po.Register(
"binary", &binary,
    59                 "Write in binary mode (only relevant if output is a wxfilename)");
    60     po.Register(
"scale", &scale,
    61                 "This option can be used to scale the matrices being copied.");
    62     po.Register(
"apply-log", &apply_log,
    63                 "This option can be used to apply log on the matrices. "    64                 "Must be avoided if matrix has negative quantities.");
    65     po.Register(
"apply-exp", &apply_exp,
    66                 "This option can be used to apply exp on the matrices");
    67     po.Register(
"apply-power", &apply_power,
    68                 "This option can be used to apply a power on the matrices");
    69     po.Register(
"apply-softmax-per-row", &apply_softmax_per_row,
    70                 "This option can be used to apply softmax per row of the matrices");
    74     if (po.NumArgs() != 2) {
    79     if ( (apply_log && apply_exp) || (apply_softmax_per_row && apply_exp) ||
    80           (apply_softmax_per_row && apply_log) )
    81       KALDI_ERR << 
"Only one of apply-log, apply-exp and "    82                 << 
"apply-softmax-per-row can be given";
    84     std::string matrix_in_fn = po.GetArg(1),
    85         matrix_out_fn = po.GetArg(2);
    89     bool in_is_rspecifier =
    96     if (in_is_rspecifier != out_is_wspecifier)
    97       KALDI_ERR << 
"Cannot mix archives with regular files (copying matrices)";
    99     if (!in_is_rspecifier) {
   102       if (scale != 1.0) mat.
Scale(scale);
   109       if (apply_power != 1.0) mat.
ApplyPow(apply_power);
   110       Output ko(matrix_out_fn, binary);
   111       mat.
Write(ko.Stream(), binary);
   112       KALDI_LOG << 
"Copied matrix to " << matrix_out_fn;
   118       for (; !reader.Done(); reader.Next(), num_done++) {
   119         if (scale != 1.0 || apply_log || apply_exp ||
   120               apply_power != 1.0 || apply_softmax_per_row) {
   122           if (scale != 1.0) mat.
Scale(scale);
   129           if (apply_power != 1.0) mat.
ApplyPow(apply_power);
   130           writer.Write(reader.Key(), mat);
   132           writer.Write(reader.Key(), reader.Value());
   135       KALDI_LOG << 
"Copied " << num_done << 
" matrices.";
   136       return (num_done != 0 ? 0 : 1);
   138   } 
catch(
const std::exception &e) {
   139     std::cerr << e.what();
 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
void Write(std::ostream &out, bool binary) const
write to stream. 
 
A templated class for writing objects to an archive or script file; see The Table concept...
 
RspecifierType ClassifyRspecifier(const std::string &rspecifier, std::string *rxfilename, RspecifierOptions *opts)
 
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
 
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
 
void Scale(Real alpha)
Multiply each element with a scalar value. 
 
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
 
void ApplySoftMaxPerRow(MatrixBase< BaseFloat > *mat)
 
WspecifierType ClassifyWspecifier(const std::string &wspecifier, std::string *archive_wxfilename, std::string *script_wxfilename, WspecifierOptions *opts)
 
void ApplyFloor(Real floor_val)
 
void ApplyPow(Real power)