예제 #1
0
파일: xor.py 프로젝트: zyx061212/Kaggle
def runExp(gamma=0, epsilon=0.1, xor=False, lr = 0.02):    
    if xor: 
        print "Attempting the XOR task"
    else:
        print "Attempting the AND task"
        
    task = XORTask()
    task.and_task = not xor
    
    l = Q_LinFA(task.nactions, task.nsenses)
    l.rewardDiscount = gamma
    l.learningRate = lr

    agent = LinFA_QAgent(l)
    agent.epsilon = epsilon
    exp = Experiment(task, agent)    
            
    sofar = 0
    for i in range(30):
        exp.doInteractions(100)
        print exp.task.cumreward - sofar,
        if i%10 == 9: 
            print                
        sofar = exp.task.cumreward          
        l._decayLearningRate()
예제 #2
0
파일: episodic.py 프로젝트: DanSGraham/code
 def __init__(self, task, agent):
     if isinstance(agent, OptimizationAgent):
         self.doOptimization = True
         self.optimizer = agent.learner
         self.optimizer.setEvaluator(task, agent.module)
         self.optimizer.maxEvaluations = self.optimizer.numEvaluations
     else:
         Experiment.__init__(self, task, agent)
예제 #3
0
 def __init__(self, task, agent):
     if isinstance(agent, OptimizationAgent):
         self.doOptimization = True
         self.optimizer = agent.learner
         self.optimizer.setEvaluator(task, agent.module)
         self.optimizer.maxEvaluations = self.optimizer.numEvaluations
     else:
         Experiment.__init__(self, task, agent)
예제 #4
0
 def _oneInteraction(self):
     """ Do an interaction between the Task and the Agent. """
     if self.doOptimization:
         raise Exception(
             'When using a black-box learning algorithm, only full episodes can be done.'
         )
     else:
         return Experiment._oneInteraction(self)
예제 #5
0
파일: episodic.py 프로젝트: DanSGraham/code
 def _oneInteraction(self):
     """ Do an interaction between the Task and the Agent. """
     if self.doOptimization:
         raise Exception('When using a black-box learning algorithm, only full episodes can be done.')
     else:
         return Experiment._oneInteraction(self)
 def __init__(self, task, multiAgent):
     assert isinstance(
         task,
         EpisodicTaskSG), "task should be the subclass of EpisodicTaskSG."
     assert isinstance(multiAgent, MultiAgent), "task should be MultAgent."
     Experiment.__init__(self, task, multiAgent)
 def __init__(self, task, multiAgent):
     assert isinstance(task, EpisodicTaskSG), "task should be the subclass of EpisodicTaskSG."
     assert isinstance(multiAgent, MultiAgent), "task should be MultAgent."
     Experiment.__init__(self, task, multiAgent)