Hi !
Thanks for sharing your codes on the music fader nets paper.
I wanted to try it for doing some random sampling, so I followed your notebook and adapted basic functions from my understanding of the model functioning.
def decode_events(model,z,out_length=100):
out = model.global_decoder(z, steps=out_length)
pm = magenta_decode_midi(clean_output(out))
return pm,out
def random_sample(model,CHROMA_DIMS,c_pitch,out_length,c_mode="major",std=1.):
chroma_dict = {"C": 0, "C#": 1, "D": 2, "D#": 3, "E": 4, "F": 5, "F#": 6, "G": 7, "G#": 8, "A": 9, "A#": 10, "B": 11}
minor_pos = 12
c = chroma_dict[c_pitch]
if c_mode=="minor":
c += minor_pos
c = torch.nn.functional.one_hot(torch.tensor([c]),num_classes=CHROMA_DIMS)
z = torch.cat([torch.normal(0.,std,size=(1, model.latent_dim)), torch.normal(0.,std,size=(1, model.latent_dim)), c], dim=1)
if torch.cuda.is_available():
z = z.cuda()
pm,out = decode_events(model,z,out_length=out_length)
return pm,out
and the midi outputs are nothing like a melody, or sometimes even getting NaNs
(here is a random pianoroll plot)
10__major_C#.pdf
When I run an auto-encode following the process shown in the notebook, I get some more reasonable outputs.
Would you have some insights on how to proceed for random sapling the model please ?