Options
All
  • Public
  • Public/Protected
  • All
Menu

Main MidiMe model class.

A MidiMe is a hierarchical variational autoencoder that is trained on latent vectors generated by MusicVAE. It allows you to personalize your own MusicVAE model with just a little data, so that samples from MidiMe sound similar to the input data.

Hierarchy

  • MidiMe

Index

Constructors

constructor

  • new MidiMe(config?: MidiMeConfig): MidiMe

Properties

config

config: MidiMeConfig

initialized

initialized: boolean = false

trained

trained: boolean = false

Methods

decode

  • decode(z: tf.Tensor2D): Promise<Tensor<Rank> | Tensor<Rank>[]>
  • Decodes a batch of latent vectors.

    Parameters

    • z: tf.Tensor2D

      The batch of latent vectors, of shape [numSamples, this.config['latent_size']].

    Returns Promise<Tensor<Rank> | Tensor<Rank>[]>

    A latent vector representing a NoteSequence. You can pass this latent vector to a MusicVAEs decode method to convert it to a NoteSequence.

dispose

  • dispose(): void

encode

  • encode(z: tf.Tensor2D): Promise<Tensor<Rank>>
  • Encodes a batch of latent vectors.

    Parameters

    • z: tf.Tensor2D

      The batch of latent vectors, of shape [numSamples, this.config['input_size']]. This is the vector that you would get from passing a NoteSequence to a MusicVAEs encode method.

    Returns Promise<Tensor<Rank>>

    A latent vector of size this.config['latent_size'].

initialize

  • initialize(): void

klLoss

  • klLoss(mu: Tensor, sigma: Tensor): tf.Scalar

predict

  • predict(z: Tensor): Tensor<R2>
  • Reconstructs an input latent vector.

    Parameters

    • z: Tensor

      The input latent vector

    Returns Tensor<R2>

    The reconstructed latent vector after running it through the model.

reconstructionLoss

  • reconstructionLoss(yTrue: Tensor, yPred: Tensor): tf.Scalar

sample

  • sample(numSamples?: number): Promise<Tensor<Rank> | Tensor<Rank>[]>
  • Samples sequences from the model prior.

    Parameters

    • Default value numSamples: number = 1

      The number of samples to return.

    Returns Promise<Tensor<Rank> | Tensor<Rank>[]>

    A latent vector representing a NoteSequence. You can pass this latent vector to a MusicVAEs decode method to convert it to a NoteSequence.

train

  • train(xTrain: Tensor, callback?: Function): Promise<void>
  • Trains the VAE on the provided data. The number of epochs to train for is taken from the model's configuration.

    Parameters

    • xTrain: Tensor
    • Optional callback: Function

      A function to be called at the end of every training epoch, containing the training errors for that epoch.

    Returns Promise<void>

Generated using TypeDoc