tf.multinomial 输出范围以外的数字

tf.multinomial outputs number other numbers than range

我正在使用 OpenAI 健身房环境(使用策略梯度)。我的网络输出的动作高于可能的动作范围。

n_outputs = 9
learning_rate = 0.01

initializer = tf.variance_scaling_initializer()

X = tf.placeholder(tf.float32, shape=[None, 50, 70, 1])
network = tflearn.conv_2d(X, 32, 5, strides=2, activation='relu')
network = tflearn.max_pool_2d(network, 2)
network = tflearn.conv_2d(network, 32, 5, strides=2, activation='relu')
network = tflearn.max_pool_2d(network, 2)
network = tflearn.fully_connected(network, 256, activation='relu')
hidden = tf.layers.dense(network, 64, activation=tf.nn.relu, kernel_initializer=initializer)
logits = tf.layers.dense(hidden, n_outputs)
outputs = tf.nn.softmax(logits)
action = tf.multinomial(outputs, num_samples=1)

它输出9,这在健身房环境中造成了错误。

full code.

如果遇到 数值错误

tf.multinomial 将在范围外采样,所以换句话说 - 你的图表中有 NaN。