コード例 #1
0
def construct_small_network_weights(input, dqn_numbers, dqn_max_number, frame_history, num_actions):
    input = tf.image.convert_image_dtype(input, tf.float32)
    with tf.variable_scope('c1'):
        c1 = th.down_convolution_weights(input, dqn_numbers, dqn_max_number, 5, 5, frame_history, 16, leaky_relu)
    with tf.variable_scope('c2'):
        c2 = th.down_convolution_weights(c1, dqn_numbers, dqn_max_number, 5, 5, 16, 4, leaky_relu)
        N = np.prod([x.value for x in c2.get_shape()[1:]])
        c2 = tf.reshape(c2, [-1, N])
    with tf.variable_scope('fc1'):
        fc1 = th.fully_connected_weights(c2, dqn_numbers, dqn_max_number, 15, leaky_relu)
    with tf.variable_scope('fc2'):
        q_values = th.fully_connected_weights(fc1, dqn_numbers, dqn_max_number, num_actions, lambda x: x)
    return q_values
コード例 #2
0
def construct_q_network_weights(input, dqn_numbers, dqn_max_number, frame_history, num_actions):
    input = tf.image.convert_image_dtype(input, tf.float32)
    with tf.variable_scope('c1'):
        c1 = th.down_convolution_weights(input, dqn_numbers, dqn_max_number, 8, 4, frame_history, 32, tf.nn.relu)
    with tf.variable_scope('c2'):
        c2 = th.down_convolution_weights(c1, dqn_numbers, dqn_max_number, 4, 2, 32, 64, tf.nn.relu)
    with tf.variable_scope('c3'):
        c3 = th.down_convolution_weights(c2, dqn_numbers, dqn_max_number, 3, 1, 64, 64, tf.nn.relu)
        N = np.prod([x.value for x in c3.get_shape()[1:]])
        # N = tf.reduce_prod(tf.shape(c3)[1:4])
        # N = []
        c3 = tf.reshape(c3, [-1, N])
    with tf.variable_scope('fc1'):
        fc1 = th.fully_connected_weights(c3, dqn_numbers, dqn_max_number, 512, tf.nn.relu)
    with tf.variable_scope('fc2'):
        q_values = th.fully_connected_weights(fc1, dqn_numbers, dqn_max_number, num_actions, lambda x: x)
    return q_values