llSourcell / Music_Generator_Demo

Music Generator Demo by @Sirajology on Youtube
246 stars 123 forks source link

Tf 0.12 compatible #3

Closed cjpurackal closed 7 years ago

cjpurackal commented 7 years ago

Made the code compatible with tensorflow 0.12.

Changes are :

*control_flow_ops.While() -> control_flow_ops.while_loop() ( This was causing the "no attribute named while" issue which was seen in some of the youtube comments)

*initialize_all_variables() -> tf.global_variables_initializer() ( initialize_all_variables() will soon be deprecated)

hb0702 commented 7 years ago

After making your change to code, I still get Traceback (most recent call last): File "/home/hanbin/Desktop/Deep Leaning/Music_Generator_Demo-master/rbm_chords.py", line 87, in x_sample = gibbs_sample(1) File "/home/hanbin/Desktop/Deep Leaning/Music_Generator_Demo-master/rbm_chords.py", line 78, in gibbs_sample gibbs_step, [ct, tf.constant(k), x], 1, False) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 2629, in while_loop raise TypeError("parallel_iterations must be a positive integer.") TypeError: parallel_iterations must be a positive integer.

Im using tensorflow .12

cjpurackal commented 7 years ago

I believe you're using the original code from this repository. The pull request hasn't been accepted, so the changes are not present in the original code. Check out the "Files Changed" tab in this pull request to know about the changes(represented in the green region)

Specifically, change the line : [, , x_sample] = control_flow_ops.While(lambda count, num_iter, *args: count < num_iter, gibbs_step, [ct, tf.constant(k), x], 1, False)

to

[, , x_sample] = control_flow_ops.while_loop(lambda count, num_iter, *args: count < num_iter,gibbs_step, [ct, tf.constant(k), x])

teerth commented 7 years ago

File "rbm_chords.py", line 116, in song = song[:np.floor(song.shape[0]/num_timesteps)*num_timesteps]

keep getting this error

cjpurackal commented 7 years ago

@teerth can you specify what the error is ? i don't see it in your comment

swarathesh commented 7 years ago

python rbm_chords.py File "rbmchords.py", line 78 [, _, x_sample] = control_flow_ops.while_loop(lambda count, num_iter, *args: count < num_iter, ^ IndentationError: unindent does not match any outer indentation level

swarathesh commented 7 years ago

getting the above error after implementing the pull code

swarathesh commented 7 years ago

change the code you mentioned with song = song[:int(np.floor(song.shape[0]/num_timesteps)*num_timesteps)] @teerth

cjpurackal commented 7 years ago

@swarathesh check the spacing in line

swarathesh commented 7 years ago

yep thanks @true-source

acocalypso commented 7 years ago

after i added your change im getting this error now: Traceback (most recent call last): File "rbm_chords.py", line 95, in W_adder = tf.mul(lr/size_bt, tf.sub(tf.matmul(tf.transpose(x), h), tf.matmul(tf.transpost(x_sample), h_sample))) AttributeError: 'module' object has no attribute 'mul'

Any idea?

EDIT:

Fixed it - according to tensorflow 1.0.0 those changed to tf.subtract, tf.multiply etc.

llSourcell commented 7 years ago

thanks!