agent.py
def learn_maybe(self):
        """
        This is the main training loop.
        The agent would leave early if the train
        attribute is not set to True and if the
        observe period hasn't been completed.

        It basically grabs a self.batch_size sample from the
        memory bank, extrans the sars observations and it
        batch trains the deep neural network
        """

        if not self.train or self.step <= self.observe:
            log.debug('No training the network. Train is set to ' + str(self.train) +
                      '. Current step is ' + str(self.step) +
                      ' and observation period will end after ' + str(self.observe))
            return

        minibatch = random.sample(self.memory, self.batch_size)
        log.debug('minibatch created. Total sample of ' + str(len(minibatch)))

        state_batch = [m[0] for m in minibatch]
        action_batch = [m[1] for m in minibatch]
        rewards_batch = [m[2] for m in minibatch]
        state_prime_batch = [m[3] for m in minibatch]
        log.debug('sars have been separated and extracted')

        value_batch = []
        readout_batch = self.perception.readout_act(state_prime_batch)
        log.debug('values of the next state have been queried')

        for i in range(len(minibatch)):
            if abs(rewards_batch[i]) == 1.0:
                value_batch.append(rewards_batch[i])
                log.debug('current memory was calculated as a terminal observation')
            else:
                value_batch.append(rewards_batch[i] + self.gamma * np.max(readout_batch[i]))
                log.debug('current memory was calculated as a non-terminal observation')
            log.debug('calculated value of ' + str(value_batch[i]))

        log.debug('training network with ' + str(len(value_batch)) + ' samples')
        self.perception.train(value_batch, action_batch, state_batch)
        log.debug('end of training')

        This is the main training loop.
        The agent would leave early if the train
        attribute is not set to True and if the
        observe period hasn't been completed.

        It basically grabs a self.batch_size sample from the
        memory bank, extrans the sars observations and it
        batch trains the deep neural network
        
This is the main training loop.
The agent would leave early if the train
attribute is not set to True and if the
observe period hasn't been completed.

It basically grabs a self.batch_size sample from the
memory bank, extrans the sars observations and it
batch trains the deep neural network
This is the main training loop . The agent would leave early if the train attribute is not set to True and if the observe period hasn ' t been completed . It basically grabs a self . batch_size sample from the memory bank extrans the sars observations and it batch trains the deep neural network
def learn_maybe(self):
        if not self.train or self.step <= self.observe:
            log.debug('No training the network. Train is set to ' + str(self.train) +
                      '. Current step is ' + str(self.step) +
                      ' and observation period will end after ' + str(self.observe))
            return
        minibatch = random.sample(self.memory, self.batch_size)
        log.debug('minibatch created. Total sample of ' + str(len(minibatch)))
        state_batch = [m[0] for m in minibatch]
        action_batch = [m[1] for m in minibatch]
        rewards_batch = [m[2] for m in minibatch]
        state_prime_batch = [m[3] for m in minibatch]
        log.debug('sars have been separated and extracted')
        value_batch = []
        readout_batch = self.perception.readout_act(state_prime_batch)
        log.debug('values of the next state have been queried')
        for i in range(len(minibatch)):
            if abs(rewards_batch[i]) == 1.0:
                value_batch.append(rewards_batch[i])
                log.debug('current memory was calculated as a terminal observation')
            else:
                value_batch.append(rewards_batch[i] + self.gamma * np.max(readout_batch[i]))
                log.debug('current memory was calculated as a non-terminal observation')
            log.debug('calculated value of ' + str(value_batch[i]))
        log.debug('training network with ' + str(len(value_batch)) + ' samples')
        self.perception.train(value_batch, action_batch, state_batch)
        log.debug('end of training')
def learn_maybe ( self ) : if not self . train or self . step <= self . observe : log . debug ( 'No training the network. Train is set to ' + str ( self . train ) + '. Current step is ' + str ( self . step ) + ' and observation period will end after ' + str ( self . observe ) ) return minibatch = random . sample ( self . memory , self . batch_size ) log . debug ( 'minibatch created. Total sample of ' + str ( len ( minibatch ) ) ) state_batch = [ m [ 0 ] for m in minibatch ] action_batch = [ m [ 1 ] for m in minibatch ] rewards_batch = [ m [ 2 ] for m in minibatch ] state_prime_batch = [ m [ 3 ] for m in minibatch ] log . debug ( 'sars have been separated and extracted' ) value_batch = [ ] readout_batch = self . perception . readout_act ( state_prime_batch ) log . debug ( 'values of the next state have been queried' ) for i in range ( len ( minibatch ) ) : if abs ( rewards_batch [ i ] ) == 1.0 : value_batch . append ( rewards_batch [ i ] ) log . debug ( 'current memory was calculated as a terminal observation' ) else : value_batch . append ( rewards_batch [ i ] + self . gamma * np . max ( readout_batch [ i ] ) ) log . debug ( 'current memory was calculated as a non-terminal observation' ) log . debug ( 'calculated value of ' + str ( value_batch [ i ] ) ) log . debug ( 'training network with ' + str ( len ( value_batch ) ) + ' samples' ) self . perception . train ( value_batch , action_batch , state_batch ) log . debug ( 'end of training' )
This is the main training loop.
This is the main training loop .
"""
        This is the main training loop.
        The agent would leave early if the train
        attribute is not set to True and if the
        observe period hasn't been completed.

        It basically grabs a self.batch_size sample from the
        memory bank, extrans the sars observations and it
        batch trains the deep neural network
        """
self