tf。多项式输出除范围以外的其他数字

时间:2018-07-04 20:59:39

标签: tensorflow deep-learning reinforcement-learning tflearn openai-gym

我正在使用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

1 个答案:

答案 0 :(得分:4)

tf.multinomial如果遇到数字错误,将在范围之外进行采样,换句话说,您的图形中有NaN。