gpt4 book ai didi

python - DRQN - 前缀张量必须是标量或向量,但锯齿张量

转载 作者:太空宇宙 更新时间:2023-11-04 00:33:39 26 4
gpt4 key购买 nike

在下面this tutorial ,我收到以下错误:

ValueError:前缀张量必须是标量或向量,但看到张量:Tensor("Placeholder_2:0", dtype=int32)

错误源于这些行:

# Take the output from the final convolutional layer and send it to a recurrent layer
# The input must be reshaped into [batch x trace x units] for rnn processing, and then returned to
# [batch x units] when sent through the upper levels
self.batch_size = tf.placeholder(dtype=tf.int32)
self.convFlat = tf.reshape(slim.flatten(self.conv4), [self.batch_size, self.trainLength, h_size])
# !!!!This is the line where error city happens!!!!
self.state_in = rnn_cell.zero_state(self.batch_size, tf.float32)

网络初始化后:

mainQN = Qnetwork(h_size, cell, 'main')

仅在 python 控制台中运行代码时,此错误仍然存​​在,因此错误是一致的。

如果有帮助,我会发布更多代码

最佳答案

还有另一种方案可以解决这个问题。

改变

self.batch_size = tf.placeholder(dtype=tf.int32)

self.batch_size = tf.placeholder(dtype=tf.int32, [])

关于python - DRQN - 前缀张量必须是标量或向量,但锯齿张量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44961181/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com