Skip to content

davidalvin/NeuralCounterpoint-Trainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NeuralCounterpoint-Trainer

Deep learning framework for training generative AI models that compose polyphonic classical music.

Overview

NeuralCounterpoint-Trainer is a TensorFlow/Keras training framework for building neural networks capable of generating multi-voice classical music.

The project trains recurrent neural networks (LSTM-based architectures) on symbolic music datasets, learning harmonic relationships between voices to generate coherent polyphonic compositions.

Unlike audio generation models, this project operates entirely on symbolic musical representations, allowing the network to learn structure, harmony, rhythm, and counterpoint directly from encoded musical sequences.


Features

  • 🎼 Symbolic MIDI music modeling
  • 🧠 Deep learning with TensorFlow/Keras
  • 🎹 Polyphonic SATB voice prediction
  • 🎵 Multi-input sequence modeling
  • 🔁 LSTM-based recurrent neural networks
  • 📈 Configurable training pipeline
  • 💾 Model checkpointing and resume training
  • ⚙️ Modular preprocessing and helper utilities

Project Structure

.
├── polybach-train-rnn.ipynb
├── GlobalConstants.py
├── HelperFunctions.py
├── mapping/
├── requirements.txt
├── init.sh
└── README.md

Installation

git clone https://github.com/davidalvin/NeuralCounterpoint-Trainer.git

cd NeuralCounterpoint-Trainer

pip install -r requirements.txt

Training

Configure your dataset paths inside the notebook:

  • Training dataset
  • Model output directory
  • Mapping files
  • Checkpoint location

Then launch the notebook:

jupyter notebook polybach-train-rnn.ipynb

or execute the provided initialization script:

bash init.sh

Model Architecture

The framework trains a multi-input recurrent neural network that learns relationships between multiple musical voices.

The architecture includes:

  • Stacked LSTM encoders
  • Dense feature fusion layers
  • Multi-output prediction heads
  • Categorical cross-entropy optimization
  • Adam optimizer
  • Checkpoint-based incremental training

Dataset

The framework expects symbolic music encoded as integer sequences derived from MIDI files.

Training datasets can be generated from collections of classical compositions or any symbolic music corpus.


Technologies

  • Python
  • TensorFlow
  • Keras
  • NumPy
  • Pandas
  • music21
  • Jupyter Notebook

Applications

This framework can be adapted for:

  • AI music composition
  • Symbolic music generation
  • Algorithmic composition
  • Computational musicology
  • Music AI research
  • Sequence modeling
  • Generative deep learning

License

This project is available under the MIT License. See the LICENSE file for details.

About

Bach harmonizer based on bach chorales, WTC and goldberg variations

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages