dshieble / Music_RNN_RBM

Generating longer musical pieces with an RNN-RBM in TensorFlow
96 stars 34 forks source link

ValueError: The shape for while_1/Merge_2:0 is not an invariant for the loop. It enters the loop with shape (1, 100), but has shape (?, 100) after one iteration. Provide shape invariants using either the `shape_invariants` argument of tf.while_loop or set_shape() on the loop variables #7

Open lirus7 opened 7 years ago

lirus7 commented 7 years ago

I tried running your code with slight tweaks which are no way related to this part but this doesnt seem to be working .

`
Uarr = tf.scan(rnn_recurrence, x, initializer=u0)

    U = Uarr[int(np.floor(prime_length / midi_manipulation.num_timesteps)), :, :]

    time_steps = tf.constant(1, tf.int32)

    iterations = tf.constant(num)

    u_t = tf.zeros([1, n_visible], tf.float32)

    music = tf.zeros([1, n_visible], tf.float32)

    loop_vars = [time_steps, iterations, U, u_t, x, music]
    [_, _, _, _, _, music] = tf.while_loop(lambda count, num_iter, *args: count < num_iter, generate_recurrence,
                                           loop_vars, shape_invariants=[time_steps, iterations,
                                                             U, u_t,x, tf.TensorShape([1, 15600])])

    return music`
junwoo091400 commented 7 years ago

Doesn't that message come from using tf.while_loop() ? I had similar message, so I gave 'shape' info after 'variable' in tf.while_loop() And, it is probably because 'music' gets concatenated every loop. So it's shape changes, eventually it will become 'num_iter' x 'n_visible' size...

vachanshetty01 commented 6 years ago

@junwoo091400: Are you saying that you've specified the 'shape_invariants' after the 'loop_vars' in the while_loop? Or have you changed something else?

I ask only because I tried adding the 'shape_invariants' but I still get the same problem.

Guije2018 commented 6 years ago

I used loop_vars = [time_steps, iterations, U, u_t, x, music] [_, _, _, _, _, music] = tf.while_loop(lambda count, num_iter, *args: count < num_iter, generate_recurrence, loop_vars, shape_invariants=[time_steps.get_shape(), iterations.get_shape(), U.get_shape(), u_t.get_shape(),x.get_shape(), tf.TensorShape([None, None])])