dqn.py
def buildModel(self, inputSize=21168):
        """ Build regression modeol that minimizes using qTarget (satisfying Bellman eq using current weights) - predictQ, train using Adam to find optimal W
        Args:
            inputSize: length of list provided as input
        Returns:
             None, updates the list of variables collected in the graph under the key GraphKeys.TRAINABLE_VARIABLES.
        Raises:
            None
        """
        # model architecture
        self.input_data = tf.placeholder(shape=[None,inputSize], dtype=tf.float32)
        l1_output = tf.contrib.layers.conv2d(inputs=tf.reshape(self.input_data, shape=[-1, 84, 84, 3]), num_outputs=self.conv_layer1['filters'],
                                     kernel_size=[self.conv_layer1['filterSize'], self.conv_layer1['filterSize']],
                                     stride=[self.conv_layer1['stride'],self.conv_layer1['stride']], padding='VALID', activation_fn=tf.nn.relu, scope='CONV1')
        l2_output = tf.contrib.layers.conv2d(inputs=l1_output, num_outputs=self.conv_layer2['filters'],
                                     kernel_size=[self.conv_layer2['filterSize'], self.conv_layer2['filterSize']],
                                     stride=[self.conv_layer2['stride'],self.conv_layer2['stride']], padding='VALID', activation_fn=tf.nn.relu, scope='CONV2')
        l3_output = tf.contrib.layers.conv2d(inputs=l2_output, num_outputs=self.conv_layer3['filters'],
                                     kernel_size=[self.conv_layer3['filterSize'], self.conv_layer3['filterSize']],
                                     stride=[self.conv_layer3['stride'],self.conv_layer3['stride']], padding='VALID', activation_fn=tf.nn.relu, scope='CONV3')
        l4_output = tf.contrib.layers.conv2d(inputs=l3_output, num_outputs=self.conv_layer4['filters'],
                                     kernel_size=[self.conv_layer4['filterSize'], self.conv_layer4['filterSize']],
                                     stride=[self.conv_layer4['stride'],self.conv_layer4['stride']], padding='VALID', activation_fn=tf.nn.relu, scope='CONV4')
        l5_output = tf.contrib.layers.fully_connected(inputs=l4_output, num_outputs=self.fc_layer1['nodes'],
                                     activation_fn=tf.nn.relu, weights_initializer=tf.contrib.layers.xavier_initializer(), scope='FC1')

        self.Q = tf.contrib.layers.fully_connected(inputs=l5_output, num_outputs=self.fc_layer2['nodes'],
                                     activation_fn=None, weights_initializer=tf.contrib.layers.xavier_initializer(), scope='FC2')
        self.best_action = tf.argmax(self.Q, axis=3, name="bestAction")

        # loss and optimizer
        q_target = tf.placeholder(shape=[None], dtype=tf.float32)
        reg_loss = tf.reduce_mean(tf.square(q_target - self.Q))
        tf.train.AdamOptimizer(self.nn_params['learning_rate']).minimize(reg_loss)
 Build regression modeol that minimizes using qTarget (satisfying Bellman eq using current weights) - predictQ, train using Adam to find optimal W
        Args:
            inputSize: length of list provided as input
        Returns:
             None, updates the list of variables collected in the graph under the key GraphKeys.TRAINABLE_VARIABLES.
        Raises:
            None
        
Build regression modeol that minimizes using qTarget (satisfying Bellman eq using current weights) - predictQ, train using Adam to find optimal W
Args:
inputSize: length of list provided as input
Returns:
None, updates the list of variables collected in the graph under the key GraphKeys.TRAINABLE_VARIABLES.
Raises:
None
Build regression modeol that minimizes using qTarget ( satisfying Bellman eq using current weights ) - predictQ train using Adam to find optimal W Args : inputSize : length of list provided as input Returns : None updates the list of variables collected in the graph under the key GraphKeys . TRAINABLE_VARIABLES . Raises : None
def buildModel(self, inputSize=21168):
        self.input_data = tf.placeholder(shape=[None,inputSize], dtype=tf.float32)
        l1_output = tf.contrib.layers.conv2d(inputs=tf.reshape(self.input_data, shape=[-1, 84, 84, 3]), num_outputs=self.conv_layer1['filters'],
                                     kernel_size=[self.conv_layer1['filterSize'], self.conv_layer1['filterSize']],
                                     stride=[self.conv_layer1['stride'],self.conv_layer1['stride']], padding='VALID', activation_fn=tf.nn.relu, scope='CONV1')
        l2_output = tf.contrib.layers.conv2d(inputs=l1_output, num_outputs=self.conv_layer2['filters'],
                                     kernel_size=[self.conv_layer2['filterSize'], self.conv_layer2['filterSize']],
                                     stride=[self.conv_layer2['stride'],self.conv_layer2['stride']], padding='VALID', activation_fn=tf.nn.relu, scope='CONV2')
        l3_output = tf.contrib.layers.conv2d(inputs=l2_output, num_outputs=self.conv_layer3['filters'],
                                     kernel_size=[self.conv_layer3['filterSize'], self.conv_layer3['filterSize']],
                                     stride=[self.conv_layer3['stride'],self.conv_layer3['stride']], padding='VALID', activation_fn=tf.nn.relu, scope='CONV3')
        l4_output = tf.contrib.layers.conv2d(inputs=l3_output, num_outputs=self.conv_layer4['filters'],
                                     kernel_size=[self.conv_layer4['filterSize'], self.conv_layer4['filterSize']],
                                     stride=[self.conv_layer4['stride'],self.conv_layer4['stride']], padding='VALID', activation_fn=tf.nn.relu, scope='CONV4')
        l5_output = tf.contrib.layers.fully_connected(inputs=l4_output, num_outputs=self.fc_layer1['nodes'],
                                     activation_fn=tf.nn.relu, weights_initializer=tf.contrib.layers.xavier_initializer(), scope='FC1')
        self.Q = tf.contrib.layers.fully_connected(inputs=l5_output, num_outputs=self.fc_layer2['nodes'],
                                     activation_fn=None, weights_initializer=tf.contrib.layers.xavier_initializer(), scope='FC2')
        self.best_action = tf.argmax(self.Q, axis=3, name="bestAction")
        q_target = tf.placeholder(shape=[None], dtype=tf.float32)
        reg_loss = tf.reduce_mean(tf.square(q_target - self.Q))
        tf.train.AdamOptimizer(self.nn_params['learning_rate']).minimize(reg_loss)
def buildModel ( self , inputSize = 21168 ) : self . input_data = tf . placeholder ( shape = [ None , inputSize ] , dtype = tf . float32 ) l1_output = tf . contrib . layers . conv2d ( inputs = tf . reshape ( self . input_data , shape = [ - 1 , 84 , 84 , 3 ] ) , num_outputs = self . conv_layer1 [ 'filters' ] , kernel_size = [ self . conv_layer1 [ 'filterSize' ] , self . conv_layer1 [ 'filterSize' ] ] , stride = [ self . conv_layer1 [ 'stride' ] , self . conv_layer1 [ 'stride' ] ] , padding = 'VALID' , activation_fn = tf . nn . relu , scope = 'CONV1' ) l2_output = tf . contrib . layers . conv2d ( inputs = l1_output , num_outputs = self . conv_layer2 [ 'filters' ] , kernel_size = [ self . conv_layer2 [ 'filterSize' ] , self . conv_layer2 [ 'filterSize' ] ] , stride = [ self . conv_layer2 [ 'stride' ] , self . conv_layer2 [ 'stride' ] ] , padding = 'VALID' , activation_fn = tf . nn . relu , scope = 'CONV2' ) l3_output = tf . contrib . layers . conv2d ( inputs = l2_output , num_outputs = self . conv_layer3 [ 'filters' ] , kernel_size = [ self . conv_layer3 [ 'filterSize' ] , self . conv_layer3 [ 'filterSize' ] ] , stride = [ self . conv_layer3 [ 'stride' ] , self . conv_layer3 [ 'stride' ] ] , padding = 'VALID' , activation_fn = tf . nn . relu , scope = 'CONV3' ) l4_output = tf . contrib . layers . conv2d ( inputs = l3_output , num_outputs = self . conv_layer4 [ 'filters' ] , kernel_size = [ self . conv_layer4 [ 'filterSize' ] , self . conv_layer4 [ 'filterSize' ] ] , stride = [ self . conv_layer4 [ 'stride' ] , self . conv_layer4 [ 'stride' ] ] , padding = 'VALID' , activation_fn = tf . nn . relu , scope = 'CONV4' ) l5_output = tf . contrib . layers . fully_connected ( inputs = l4_output , num_outputs = self . fc_layer1 [ 'nodes' ] , activation_fn = tf . nn . relu , weights_initializer = tf . contrib . layers . xavier_initializer ( ) , scope = 'FC1' ) self . Q = tf . contrib . layers . fully_connected ( inputs = l5_output , num_outputs = self . fc_layer2 [ 'nodes' ] , activation_fn = None , weights_initializer = tf . contrib . layers . xavier_initializer ( ) , scope = 'FC2' ) self . best_action = tf . argmax ( self . Q , axis = 3 , name = "bestAction" ) q_target = tf . placeholder ( shape = [ None ] , dtype = tf . float32 ) reg_loss = tf . reduce_mean ( tf . square ( q_target - self . Q ) ) tf . train . AdamOptimizer ( self . nn_params [ 'learning_rate' ] ) . minimize ( reg_loss )
Build regression modeol that minimizes using qTarget (satisfying Bellman eq using current weights) - predictQ, train using Adam to find optimal W
Args:
inputSize: length of list provided as input
Returns:
None, updates the list of variables collected in the graph under the key GraphKeys.TRAINABLE_VARIABLES.
Build regression modeol that minimizes using qTarget ( satisfying Bellman eq using current weights ) - predictQ train using Adam to find optimal W Args : inputSize : length of list provided as input Returns : None updates the list of variables collected in the graph under the key GraphKeys . TRAINABLE_VARIABLES .
""" Build regression modeol that minimizes using qTarget (satisfying Bellman eq using current weights) - predictQ, train using Adam to find optimal W
        Args:
            inputSize: length of list provided as input
        Returns:
             None, updates the list of variables collected in the graph under the key GraphKeys.TRAINABLE_VARIABLES.
        Raises:
            None
        """ # model architecture # loss and optimizer
self
inputSize