(batch,
                     timesteps=1,
                     n_pitches=128,
                     dim_embedding=128,
                     reuse=False)
Get a embedding of each pitch note.

  Args:
    batch: NSynthDataset batch dictionary.
    timesteps: Number of timesteps to replicate across.
    n_pitches: Number of one-hot embeddings.
    dim_embedding: Dimension of linear projection of one-hot encoding.
    reuse: Reuse variables.

  Returns:
    embedding: A tensor of shape [batch_size, 1, timesteps, dim_embedding].
Get a embedding of each pitch note.
Get a embedding of each pitch note .
def pitch_embeddings(batch,
                     timesteps=1,
                     n_pitches=128,
                     dim_embedding=128,
                     reuse=False):
  """Get a embedding of each pitch note.

  Args:
    batch: NSynthDataset batch dictionary.
    timesteps: Number of timesteps to replicate across.
    n_pitches: Number of one-hot embeddings.
    dim_embedding: Dimension of linear projection of one-hot encoding.
    reuse: Reuse variables.

  Returns:
    embedding: A tensor of shape [batch_size, 1, timesteps, dim_embedding].
  """
  batch_size = batch["pitch"].get_shape().as_list()[0]
  with tf.variable_scope("PitchEmbedding", reuse=reuse):
    w = tf.get_variable(
        name="embedding_weights",
        shape=[n_pitches, dim_embedding],
        initializer=tf.random_normal_initializer())
    one_hot_pitch = tf.reshape(batch["pitch"], [batch_size])
    one_hot_pitch = tf.one_hot(one_hot_pitch, depth=n_pitches)
    embedding = tf.matmul(one_hot_pitch, w)
    embedding = tf.reshape(embedding, [batch_size, 1, 1, dim_embedding])
    if timesteps > 1:
      embedding = tf.tile(embedding, [1, 1, timesteps, 1])
    return embedding
def pitch_embeddings ( batch , timesteps = 1 , n_pitches = 128 , dim_embedding = 128 , reuse = False ) : batch_size = batch [ "pitch" ] . get_shape ( ) . as_list ( ) [ 0 ] with tf . variable_scope ( "PitchEmbedding" , reuse = reuse ) : w = tf . get_variable ( name = "embedding_weights" , shape = [ n_pitches , dim_embedding ] , initializer = tf . random_normal_initializer ( ) ) one_hot_pitch = tf . reshape ( batch [ "pitch" ] , [ batch_size ] ) one_hot_pitch = tf . one_hot ( one_hot_pitch , depth = n_pitches ) embedding = tf . matmul ( one_hot_pitch , w ) embedding = tf . reshape ( embedding , [ batch_size , 1 , 1 , dim_embedding ] ) if timesteps > 1 : embedding = tf . tile ( embedding , [ 1 , 1 , timesteps , 1 ] ) return embedding