Options
All
  • Public
  • Public/Protected
  • All
Menu

Main MusicVAE model class.

A MusicVAE is a variational autoencoder made up of an Encoder and Decoder, along with a DataConverter for converting between Tensor and NoteSequence objects for input and output.

Exposes methods for interpolation and sampling of musical sequences.

Hierarchy

  • MusicVAE

Index

Constructors

constructor

  • MusicVAE constructor.

    Parameters

    • checkpointURL: string

      Path to the checkpoint directory.

    • Optional spec: MusicVAESpec

      (Optional) MusicVAESpec object. If undefined, will be loaded from a config.json file in the checkpoint directory.

    Returns MusicVAE

Properties

initialized

initialized: boolean = false

Methods

decode

  • decode(z: tf.Tensor2D, temperature?: number, chordProgression?: string[], stepsPerQuarter?: number): Promise<INoteSequence[]>
  • Decodes the input latnet vectors into NoteSequences.

    Parameters

    • z: tf.Tensor2D

      The latent vectors to decode, sized [batchSize, zSize].

    • Optional temperature: number

      (Optional) The softmax temperature to use when sampling. The argmax is used if not provided.

    • Optional chordProgression: string[]

      (Optional) Chord progression to use as conditioning.

    • Default value stepsPerQuarter: number = 4

      The step resolution of the resulting NoteSequence.

    Returns Promise<INoteSequence[]>

    The decoded NoteSequences.

dispose

  • dispose(): void

encode

  • encode(inputSequences: INoteSequence[], chordProgression?: string[]): Promise<Tensor<R2>>
  • Encodes the input NoteSequences into latent vectors.

    Parameters

    • inputSequences: INoteSequence[]

      An array of NoteSequences to encode.

    • Optional chordProgression: string[]

      (Optional) Chord progression to use as conditioning.

    Returns Promise<Tensor<R2>>

    A Tensor containing the batch of latent vectors, sized [inputSequences.length, zSize].

initialize

  • initialize(): Promise<void>
  • Loads variables from the checkpoint and instantiates the Encoder and Decoder.

    Returns Promise<void>

interpolate

  • interpolate(inputSequences: INoteSequence[], numInterps: number | number[], temperature?: number, chordProgression?: string[]): Promise<INoteSequence[]>
  • Interpolates between the input NoteSequences in latent space.

    If 2 sequences are given, a single linear interpolation is computed, with the first output sequence being a reconstruction of sequence A and the final output being a reconstruction of sequence B, with numInterps total sequences.

    If 4 sequences are given, bilinear interpolation is used. The results are returned in row-major order for a matrix with the following layout: | A . . C | | . . . . | | . . . . | | B . . D | where the letters represent the reconstructions of the four inputs, in alphabetical order, with the number of output columns and rows specified by numInterps.

    Parameters

    • inputSequences: INoteSequence[]

      An array of 2 or 4 NoteSequences to interpolate between.

    • numInterps: number | number[]

      The number of pairwise interpolation sequences to return, including the reconstructions. If 4 inputs are given, this can be either a single number specifying the side length of a square, or a [columnCount, rowCount] array to specify a rectangle.

    • Optional temperature: number

      (Optional) The softmax temperature to use when sampling from the logits. Argmax is used if not provided.

    • Optional chordProgression: string[]

      (Optional) Chord progression to use as conditioning.

    Returns Promise<INoteSequence[]>

    An array of interpolation NoteSequence objects, as described above.

isInitialized

  • isInitialized(): boolean

sample

  • sample(numSamples: number, temperature?: number, chordProgression?: string[], stepsPerQuarter?: number): Promise<INoteSequence[]>
  • Samples sequences from the model prior.

    Parameters

    • numSamples: number

      The number of samples to return.

    • Default value temperature: number = 0.5

      The softmax temperature to use when sampling.

    • Optional chordProgression: string[]

      (Optional) Chord progression to use as conditioning.

    • Default value stepsPerQuarter: number = constants.DEFAULT_STEPS_PER_QUARTER

      The step resolution of the resulting NoteSequences.

    Returns Promise<INoteSequence[]>

    An array of sampled NoteSequence objects.

Generated using TypeDoc