def get_config(batch_size, data_path): return configs.Config( model=MusicVAE(lstm_models.BidirectionalLstmEncoder(), lstm_models.CategoricalLstmDecoder()), hparams=merge_hparams( lstm_models.get_default_hparams(), HParams( batch_size=512, max_seq_len=32, # 2 bars w/ 16 steps per bar z_size=512, enc_rnn_size=[2048], dec_rnn_size=[2048, 2048, 2048], free_bits=0, max_beta=0.5, beta_rate=0.99999, sampling_schedule='inverse_sigmoid', sampling_rate=1000, )), note_sequence_augmenter=data.NoteSequenceAugmenter( transpose_range=(-5, 5)), data_converter=data.OneHotMelodyConverter( valid_programs=data.MEL_PROGRAMS, skip_polyphony=False, max_bars=100, # Truncate long melodies before slicing. slice_bars=2, steps_per_quarter=4), train_examples_path=data_path, eval_examples_path=data_path, )
Config.__new__.__defaults__ = (None, ) * len(Config._fields) def update_config(config, update_dict): config_dict = config.values() config_dict.update(update_dict) return Config(**config_dict) CONFIG_MAP = {} # Melody CONFIG_MAP['cat-mel_2bar_small'] = Config( model=MusicVAE(lstm_models.BidirectionalLstmEncoder(), lstm_models.CategoricalLstmDecoder()), hparams=merge_hparams( lstm_models.get_default_hparams(), HParams( batch_size=512, max_seq_len=32, # 2 bars w/ 16 steps per bar z_size=256, enc_rnn_size=[512], dec_rnn_size=[256, 256], free_bits=0, max_beta=0.2, beta_rate=0.99999, sampling_schedule='inverse_sigmoid', sampling_rate=1000, )), note_sequence_augmenter=data.NoteSequenceAugmenter(transpose_range=(-5,
])): def values(self): return self._asdict() def update_config(config, update_dict): config_dict = config.values() config_dict.update(update_dict) return Config(**config_dict) config_map = {} # Melody config_map['cat-mel_2bar_small'] = Config( model=MusicVAE(lstm_models.BidirectionalLstmEncoder(), lstm_models.CategoricalLstmDecoder()), hparams=merge_hparams( lstm_models.get_default_hparams(), HParams( batch_size=512, max_seq_len=32, # 2 bars w/ 16 steps per bar z_size=256, enc_rnn_size=[512], dec_rnn_size=[256, 256], )), note_sequence_augmenter=None, note_sequence_converter=data.OneHotMelodyConverter( valid_programs=data.MEL_PROGRAMS, skip_polyphony=True, max_bars=100, # Truncate long melodies before slicing. slice_bars=2,
note3_set.append(sequence) # note_seq.play_sequence(sequence, synth=note_seq.synthesize) count += 1 # initializes a 16 bar trio model to train trio_16bar_converter = data.TrioConverter(steps_per_quarter=4, slice_bars=16, gap_bars=2) # simplest version of the 16 bar trio because it has the largest size # and I can understand it best CONFIG_MAP['flat-trio_16bar'] = Config( model=MusicVAE( lstm_models.BidirectionalLstmEncoder(), lstm_models.MultiOutCategoricalLstmDecoder(output_depths=[ 90, # melody 90, # bass 512, # drums ])), hparams=merge_hparams( lstm_models.get_default_hparams(), HParams( batch_size=256, max_seq_len=256, z_size=512, enc_rnn_size=[2048, 2048], dec_rnn_size=[2048, 2048, 2048], )), note_sequence_augmenter=None, data_converter=trio_16bar_converter, train_examples_path='./MidiSet1/',