Counterpoint by Convolution

Cheng-Zhi Anna Huang, Tim Cooijmans, Adam Roberts, Aaron C. Courville, Douglas EckarXiv 2019

Abstract

Traditional music generation models often rely on sequential, chronological prediction, which fails to capture the non-linear nature of human composition. This paper introduces COCONET, a deep convolutional neural network that treats musical scores as images to be "inpainted." By employing orderless NADE training and blocked Gibbs sampling, COCONET effectively models the complex multi-directional dependencies of polyphonic counterpoint. Experimental results on J.S. Bach chorales demonstrate that COCONET significantly outperforms state-of-the-art recurrent models, particularly at high temporal resolutions.

Introduction

Most machine learning models for music, such as Recurrent Neural Networks (RNNs) or Hidden Markov Models (HMMs), treat composition as a chronological, one-way process. They predict the next note based solely on preceding context. However, human composition is inherently non-linear; a composer may start with a central melody, add a bass line, and iteratively refine earlier sections.

Polyphonic counterpoint—where multiple independent voices must harmonize—presents a significant challenge for sequential models. Interleaving multiple voices into a single stream often obscures the local spatial relationships between notes in both time and pitch. COCONET addresses these challenges by treating music as a spatial entity, allowing for multi-directional dependencies and iterative refinement.

Methodology

COCONET is a deep convolutional neural network (CNN) designed for musical "inpainting."

Representation and Architecture

Music is represented as a 3D tensor with dimensions for instruments, time, and pitch. This "Piano Roll" representation allows the CNN to treat time and pitch as spatial dimensions, leveraging translation invariance—the principle that a musical motif remains logically consistent regardless of its position in time or its transposition in pitch. The architecture consists of a 64-layer CNN with 128 channels and residual connections to facilitate deep learning.

Training and Sampling

The model is trained using an "orderless" Neural Autoregressive Distribution Estimator (NADE) framework. During training, random subsets of notes are masked, and the model learns to reconstruct them based on the surrounding context.

For generation, COCONET utilizes blocked Gibbs sampling. Unlike standard ancestral sampling, which fills in notes one by one, Gibbs sampling allows the model to start with a rough draft and iteratively "rewrite" sections. By repeatedly masking and re-sampling, the model can correct earlier errors and settle into a more coherent musical state.

Iterative music generation process using blocked Gibbs sampling.

Experimental Results

The model was evaluated on the J.S. Bach chorales dataset across three temporal resolutions: quarter-note, eighth-note, and sixteenth-note.

Quantitative Performance

COCONET achieved significantly lower framewise negative log-likelihood (NLL) compared to previous state-of-the-art models like RNN-NADE. As shown in the table below, the performance gap widens at higher temporal resolutions, where COCONET's ability to capture local dependencies is most advantageous.

Quantitative comparison of COCONET against baseline models.

Qualitative Evaluation

Human evaluation via Amazon Mechanical Turk confirmed these findings. Listeners compared COCONET-generated samples to original Bach pieces. Samples produced via Gibbs sampling were perceived as significantly more "Bach-like" than those from standard ancestral sampling, with many listeners finding the iterative generations nearly as convincing as the original compositions.

Conclusion and Future Work

COCONET demonstrates that treating music as a spatial, multi-directional structure allows for superior modeling of complex counterpoint. The iterative "rewriting" enabled by Gibbs sampling is crucial for high-quality generation. While the model excels at local texture and counterpoint, future work will focus on incorporating higher-level musical features to guide long-term global structure, which remains a challenge for purely convolutional approaches.

Summary updated

BibTeX
@misc{huang2019counterpoint,
  author = {Cheng-Zhi Anna Huang and Tim Cooijmans and Adam Roberts and Aaron C. Courville and Douglas Eck},
  title = {{Counterpoint by Convolution}},
  year = {2019},
  eprint = {1903.07227},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1903.07227},
}
Figure