Deep learning framework for training generative AI models that compose polyphonic classical music.
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.
- 🎼 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
.
├── polybach-train-rnn.ipynb
├── GlobalConstants.py
├── HelperFunctions.py
├── mapping/
├── requirements.txt
├── init.sh
└── README.md
git clone https://github.com/davidalvin/NeuralCounterpoint-Trainer.git
cd NeuralCounterpoint-Trainer
pip install -r requirements.txtConfigure your dataset paths inside the notebook:
- Training dataset
- Model output directory
- Mapping files
- Checkpoint location
Then launch the notebook:
jupyter notebook polybach-train-rnn.ipynbor execute the provided initialization script:
bash init.shThe 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
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.
- Python
- TensorFlow
- Keras
- NumPy
- Pandas
- music21
- Jupyter Notebook
This framework can be adapted for:
- AI music composition
- Symbolic music generation
- Algorithmic composition
- Computational musicology
- Music AI research
- Sequence modeling
- Generative deep learning
This project is available under the MIT License. See the LICENSE file for details.