def test_03_model(self): n = Net(Net.ALL, training_epochs=25, epochs_per_save=5, epochs_per_archve=10, save_m=True, gen_steps=60, kwargs={'hidden_size': 32}) # Should not load - no files self.assertFalse(n.load()) # Should train and gen output n.train() y = n.gen() filepath = os.path.join(test_output_dir, 'test1.wav') utils.write_output(filepath, y) # Build new model and load weights m = Net(Net.ALL, build=False, gen_steps=60, kwargs={'hidden_size': 32}) self.assertTrue(m.load()) y = m.gen() filepath = os.path.join(test_output_dir, 'test2.wav') utils.write_output(filepath, y) # Let us confirm our files were saved files = filter(lambda e: e[0] != '.', os.listdir(test_output_dir)) self.assertEqual(len(files), 2)
def main(files=files): """ Generates music and saves to filenames set in command line args, or in config.output.default_file. Runs automatically from command line. Arguments: list:files -- List of files, taken from args when run on command line """ # Build net print('Loading net...') net = Net(Net.GEN) print('Loading model...') net.load() # Generate for filepath in filepaths: y = net.gen() print('Finished generating "{0}."'.format(filepath)) sclog('Generated "{0}."'.format(filepath)) utils.write_output(filepath, y) if (cf.output.save_raw): utils.save_array(os.path.splitext(filepath)[0], y)
def main(): # We set autosave to true even if it is False in config net = Net(Net.TRAIN, autosave=True) # Simplified parameters for setting epochs for k in cf.flags.keys(): if utils.is_str_int(k): net.set(training_epochs=int(k)) break # Load weights unless new flag provided if not cf.flags.get('new'): net.load() print('Completed {0} epochs. Training next {1}...'.format( net.epochs, net.training_epochs)) net.train() sclog('Finished training {0} epochs.'.format(net.training_epochs))