作家
登录

深度强化学习入门:用TensorFlow构建你的第一个游戏AI

作者: 来源: 2017-11-21 10:53:27 阅读 我要评论

        self.discount = discount 
  •  
  •     def remember(self, states, game_over): 
  •         #Save a state to memory 
  •         self.memory.append([states, game_over]) 
  •         #We don't want to store infinite memories, so if we have too many, we just delete the oldest one 
  •         if len(self.memory) > self.max_memory: 
  •             del self.memory[0] 
  •  
  •     def get_batch(self, model, batch_size=10): 
  •          
  •         #How many experiences do we have? 
  •         len_memory = len(self.memory) 
  •          
  •         #Calculate the number of actions that can possibly be taken in the game 
  •         num_actions = model.output_shape[-1] 
  •          
  •         #Dimensions of the game field 
  •         env_dim = self.memory[0][0][0].shape[1] 
  •          
  •         #We want to return an input and target vector with inputs from an observed state... 
  •         inputs = np.zeros((min(len_memory, batch_size), env_dim)) 
  •          
  •         #...and the target r + gamma * max Q(s’,a’) 
  •         #Note that our target is a matrix, with possible fields not only for the action taken but also 
  •         #for the other possible actions. The actions not take the same value as the prediction to not affect them 
  •         targets = np.zeros((inputs.shape[0], num_actions)) 
  •          
  •         #We draw states to

      推荐阅读

      什么是云计算数据中心?云计算数据中心和传统IDC有何区别?

    Tech Neo技巧沙龙 | 11月25号,九州云/ZStack与您一路商量云时代收集界线治理实践 传统小IDC存活将更难,那么必>>>详细阅读


    本文标题:深度强化学习入门:用TensorFlow构建你的第一个游戏AI

    地址:http://www.17bianji.com/lsqh/39071.html

  • 关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)