数据集和代码均已上传到Github中,欢迎大家下载使用。
Github地址:https://github.com/JasonZhang156/Sound-Recognition-Tutorial
如果这个教程对您有所帮助,请不吝贡献您的小星星Q^Q.
测试模型
这部分比较简单,一共包含:读取测试样本、导入模型、测试模型几个步骤。直接看代码:
# -*- coding: utf-8 -*-
"""
@author: Jason Zhang
@github: https://github.com/JasonZhang156/Sound-Recognition-Tutorial
"""
from keras.models import load_model
import tensorflow as tf
import esc10_input
import numpy as np
import os
def use_gpu():
"""Configuration for GPU"""
from keras.backend.tensorflow_backend import set_session
os.environ['CUDA_VISIBLE_DEVICES'] = str(0)
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.5
config.gpu_options.allow_growth = True