Skip to content

About

A practical introduction to machine learning for hearing science.

Resources

Stars

10 stars

Watchers

1 watching

Forks

Repository files navigation

Auditory modeling and machine learning in PyTorch

This tutorial aims to introduce auditory modeling and optimization in PyTorch, a machine learning framework for the Python programming language. Some reasons to consider using PyTorch include:

  • High-performance computing: computational models can be efficiently run at scale on (multiple) CPUs or GPUs with minimal code modification.
  • Neural network compatibility: models can be integrated with artificial neural networks, which are readily implemented in PyTorch.
  • Automatic differentiation: modern machine learning relies heavily on gradient descent algorithms, in which model parameters are optimized to minimize a loss function. This requires iteratively adjusting parameters according to the gradient of the loss function with respect to said parameters. Machine learning frameworks like PyTorch have automatic differentiation, meaning they automatically calculate and keep track of these gradients (greatly simplifying the code needed to train a model).

To illustrate some of these advantages for hearing science applications, the DEMO notebook walks through:

  1. A simple, differentiable auditory nerve model implemented in PyTorch
  2. Crudely simulating peripheral effects of hearing loss
  3. Defining a model-based loss function for hearing aid optimization
  4. Optimizing hearing aid parameters via gradient descent

Hearing aid optimization for an auditory model-based loss function

Requirements

The DEMO notebook was designed be run in Google Colab, which requires a Google account. The notebook can also be run locally with minimal Python 3.9+ requirements, though access to a CUDA-enabled GPU is highly recommended. The free-tier GPU available through Google Colab is sufficient.

Open In Colab

Contents

auditory_machine_learning
|__ DEMO.ipynb           <-- Main demo notebook (start here)
|__ example_datasets.py  <-- PyTorch dataset classes to generate or load sound waveforms
|__ example_plots.py     <-- Functions to generate visualizations in the demo notebook
|__ filters.py           <-- Python filter implementations
|__ modules.py           <-- PyTorch modules for auditory modeling
|__ utils.py             <-- Helper functions for plotting and audio manipulation
|__ requirements.txt     <-- Python packages needed to run this code
|__ data                 <-- Small dataset of 100 brief speech clips
    |__ 000.wav
    |__ 001.wav
        ...
    |__ 099.wav

Citations

The code provided here has been adapted from my own research:

Contact

Mark R. Saddler (marksa@dtu.dk)

About

A practical introduction to machine learning for hearing science.

Resources

Stars

10 stars

Watchers

1 watching

Forks

Contributors

Languages