数据集和代码均已上传到Github中,欢迎大家下载使用。
Github地址:https://github.com/JasonZhang156/Sound-Recognition-Tutorial
如果这个教程对您有所帮助,请不吝贡献您的小星星Q^Q.
构建模型
本节使用keras搭建一个简单的CNN模型。该CNN模型包括3个卷积层、3个池化层、2个全连接层,中间层激活函数使用ReLU,最后一层使用softmax,每个卷积层后使用 Batch Normalization加速训练。优化器使用SGD,损失函数使用交叉熵(Cross Entropy)。模型详细配置如下:
Keras实现代码如下:
# -*- coding: utf-8 -*-
"""
@author: Jason Zhang
@github: https://github.com/JasonZhang156/Sound-Recognition-Tutorial
"""
from keras.layers import Input
from keras.layers import Conv2D, MaxPool2D, Dense, Dropout, BatchNormalization, Ac