Nnet读取
Nnet nnet;
nnet.Read(model_filename);
nnet.SetTrainOptions(trn_opts);
- 声明nnet
- std::vector<Component *> components_;用于存储每一个component
- std::vector<CuMatrix<BaseFloat>> propagate_buf_,backpropagate_buf_;
两个用于前向和后向的buffer(显存)
- NnetTrainOptions opts_; 用于存储learningrate,momentum,L1,L2
- 利用model_filename读取模型和SetTrainOptions设置learningrate等参数
- 读模型的时候需要前一个component的输出维度==后一个component的输入维度
- propagate_buf_.resize(NumComponents()+1);backpropagate_buf_.resize(NumComponents()+1);
- opts_.learn_rate=0.0
构建映射表
std::map<std::string, int32> map_utt2spk;
if (utt2spk != "") {
std::ifstream fi_map(utt2spk.c_str());
if (!fi_map) {
KALDI_ERR << "failed to open file " << utt2spk;
}
std::string key;
int32 value;
while (fi_map >> key >> value) {
map_utt2spk[key] = value;
}
}
- 这里的key为utterance-id (注意区分utterance-id和recording-id)
- 这里的value为0-speakernum-1的数值,对应speaker_code矩阵的行号
网友评论