TensorFlow - 形状不匹配

时间:2017-08-29 16:26:15

标签: python-3.x tensorflow

我刚开始使用TensorFlow。我正在https://github.com/Conchylicultor/MusicGenerator

查看MusicGenerator

我收到错误:

  

ValueError:尝试共享变量   rnn_decoder / KeyboardCell /解码器/ multi_rnn_cell / cell_0 / basic_lstm_cell /内核   但是指定了形状(1024,2048)并找到了形状(525,2048)。

我认为这可能是由于单元的编码器和解码器之间共享的一些变量。主代码是为tensorflow 0.10.0编写的,但我试图在Tensorflow 1.3上运行

def __call__(self, prev_keyboard, prev_state, scope=None):
    """ Run the cell at step t
    Args:
        prev_keyboard: keyboard configuration for the step t-1 (Ground truth or previous step)
        prev_state: a tuple (prev_state_enco, prev_state_deco)
        scope: TensorFlow scope
    Return:
        Tuple: the keyboard configuration and the enco and deco states
    """

    # First time only (we do the initialisation here to be on the global rnn loop scope)
    if not self.is_init:
        with tf.variable_scope('weights_keyboard_cell'):
            # TODO: With self.args, see which network we have chosen (create map 'network name':class)
            self.encoder.build()
            self.decoder.build()

            prev_state = self.encoder.init_state(), self.decoder.init_state()
            self.is_init = True

    # TODO: If encoder act as VAE, we should sample here, from the previous state

    # Encoder/decoder network
    with tf.variable_scope(scope or type(self).__name__):
        with tf.variable_scope('Encoder'):
            # TODO: Should be enco_output, enco_state
            next_state_enco = self.encoder.get_cell(prev_keyboard, prev_state)
        with tf.variable_scope('Decoder'):  # Reset gate and update gate.
            next_keyboard, next_state_deco = self.decoder.get_cell(prev_keyboard, (next_state_enco, prev_state[1]))
    return next_keyboard, (next_state_enco, next_state_deco)

我对RNN和CNN完全陌生。我也在阅读一些关于它的内容,并以高层次的方式理解这些是如何工作的。并了解代码的某些部分实际上是如何在培训,建模中工作的。但我认为调试这个问题还不够。特别是因为我对tensorflow API也有点困惑。

为什么这可能会发生,我能做些什么来修复它会很棒。如果你能指出一些有关CNN,RNN,Back propogation以及如何有效地使用张量流来构建东西的书籍。

0 个答案:

没有答案