Created
November 11, 2018 21:39
-
-
Save NMZivkovic/52b7629e2ed7f577302f4ff59cc3f989 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generateSongs(self, songs): | |
with tf.Session() as sess: | |
init = tf.global_variables_initializer() | |
sess.run(init) | |
for epoch in tqdm(range(self.num_of_epochs)): | |
for song in songs: | |
song = np.array(song) | |
song = song[:int(np.floor(song.shape[0]/self.num_timesteps)*self.num_timesteps)] | |
song = np.reshape(song, [song.shape[0]/self.num_timesteps, song.shape[1]*self.num_timesteps]) | |
for i in range(1, len(song), self.batch_size): | |
tr_x = song[i:i+self.batch_size] | |
sess.run(self._updates, feed_dict={self._input: tr_x}) | |
sample = self.gibsSampling(1).eval(session=sess, feed_dict={self._input: np.zeros((50, self._visible_dim))}) | |
for i in range(sample.shape[0]): | |
if not any(sample[i,:]): | |
continue | |
matrix = np.reshape(sample[i,:], (self.num_timesteps, 2*self._midi_coordinator._span)) | |
self._midi_coordinator.matrixToMidi(matrix, "song_{}".format(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment