**
tensorflow训练自己的声音数据集进行声音分类
**
环境 win10
anaconda3.5
tensorflow 2.0
1.安装anaconda
https://pan.baidu.com/s/1XeFxohUN10FPV1QF3E-X5w 密码:i60b
- 创建虚拟环境
conda create -n tensorflow python=3.7 - 启动虚拟环境
conda activate tensorflow
4.安装 tensorflow2.0
pip install tensorflow==2.0
无法下载需要修改默认路径 - 安装 librosa
pip install librosa
中间可能会失败,多安几次,如果还是失败需要下载安装
https://pan.baidu.com/s/1VWvw_CNApqCwpG0VmR-z3g 密码:37ib
cd librosa-0.8.0
python setup.py install
如果报错 Failed to build pyaudio
需要安装pyaudio
https://pan.baidu.com/s/1XryzOc1p7N0mHnmNaLvckw 密码:proh
pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl
pip install pydub
试一下
(tensorflow) F:\Tensorflow>python
Python 3.7.10 | packaged by conda-forge | (default, Feb 19 2021, 15:37:01) [MSC v.1916 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
import tensorflow
exit()
6.下载程序
https://pan.baidu.com/s/12B95Qwvlx8msIeuotLvCkg 密码:ja6n
7.运行程序 进行训练
cd AudioClassification
python train.py
(tensorflow) F:\Tensorflow\AudioClassification>python train.py
2021-03-22 14:54:14.428562: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Model: “sequential”
Layer (type) Output Shape Param #
resnet50v2 (Model) (None, 4, None, 2048) 23558528
activity_regularization (Act (None, 4, None, 2048) 0
dropout (Dropout) (None, 4, None, 2048) 0
global_max_pooling2d (Global (None, 2048) 0
dense (Dense) (None, 10) 20490
Total params: 23,579,018
Trainable params: 23,533,578
Non-trainable params: 45,440
Batch 0, Loss 1.945332, Accuracy 0.187500
Batch 20, Loss 3.135965, Accuracy 0.312500
Batch 40, Loss 4.096233, Accuracy 0.531250
Batch 60, Loss 2.204610, Accuracy 0.500000
Batch 80, Loss 3.273754, Accuracy 0.687500
Batch 100, Loss 1.581592, Accuracy 0.906250
Batch 120, Loss 2.359572, Accuracy 0.750000
Batch 140, Loss 4.610085, Accuracy 0.593750
Batch 160, Loss 2.782383, Accuracy 0.718750
Batch 180, Loss 2.560995, Accuracy 0.812500
Batch 200, Loss 2.664778, Accuracy 0.812500
Test, Loss 2.782835, Accuracy 0.833333
Batch 220, Loss 3.542227, Accuracy 0.781250