【语音识别】基于DNN |
您所在的位置:网站首页 › 利用Python计算hmm › 【语音识别】基于DNN |
基于DNN-HMM的语音识别系统
1、数据说明
本次实验所用的数据为0-9(其中0的标签为Z(Zero))和O这11个字符的英文录音所提取的39维的MFCC特征。其中 训练数据:330句话,11个字符,每个字符30句话,训练数据位于train目录下。测试数据:110句话,11个字符,每个字符10句话,测试数据位于test目录下。train/test目录下各有3个文件,分别如下: text: 标注文件,每一行第一列为句子id,第二列为标注。feats.scp: 特征索引文件,每一行第一列为句子id,第二列为特征的索引表示。feats.ark: 特征实际存储文件,该文件为二进制文件。 2、实验内容本实验实现了一个简单的DNN的框架,使用DNN进行11个数字的训练和识别。 实验中使用以上所述的训练和测试数据分别对该DNN进行训练和测试。 请阅读dnn.py中的代码,理解该DNN框架,完善ReLU激活函数和FullyConnect全连接层的前向后向算法。 可以参考Softmax的前向和后向实现。dnn.py中代码插入位置为。 # BEGIN_LAB # write your code here # END_LAB 3、运行和检查使用如下命令运行该实验,该程序末尾会打印出在测试集上的准确率。假设实现正确,应该得到95%以上的准确率,实现分类准确率为99.49%。 python dnn.py import math import matplotlib import matplotlib.pyplot as plt import numpy as np import kaldi_io from utils import * def plot_spectrogram(spec, file_name): fig = plt.figure(figsize=(20, 10)) plt.plot(spec) plt.xlabel('epochs') plt.ylabel('loss') plt.savefig(file_name) plt.show() targets_list = ['Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'O'] targets_mapping = {} for i, x in enumerate(targets_list): targets_mapping[x] = i class Layer: def forward(self, input): ''' Forward function by input Args: input: input, B * N matrix, B for batch size Returns: output when applied this layer ''' raise 'Not implement error' def backward(self, input, output, d_output): ''' Compute gradient of this layer's input by (input, output, d_output) as well as compute the gradient of the parameter of this layer Args: input: input of this layer output: output of this layer d_output: accumulated gradient from final output to this layer's output Returns: accumulated gradient from final output to this layer's input ''' raise 'Not implement error' def set_learning_rate(self, lr): ''' Set learning rate of this layer''' self.learning_rate = lr def update(self): ''' Update this layers parameter if it has or do nothing ''' class ReLU(Layer): def forward(self, input): mat = np.maximum(0, input) return mat.T def backward(self, input, output, d_output): mat = np.array(d_output, copy=True) mat[input |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |