作家
登录

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

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

  •     #Reseting the win counter 
  •     win_cnt = 0 
  •     # We want to keep track of the progress of the AI over time, so we save its win count history 
  •     win_hist = [] 
  •     #Epochs is the number of games we play 
  •     for e in range(epochs): 
  •         loss = 0. 
  •         #Resetting the game 
  •         env.reset() 
  •         game_over = False 
  •         # get initial input 
  •         input_t = env.observe() 
  •          
  •         while not game_over: 
  •             #The learner is acting on the last observed game screen 
  •             #input_t is a vector containing representing the game screen 
  •             input_tm1 = input_t 
  •              
  •             #Take a random action with probability epsilon 
  •             if np.random.rand() <= epsilon: 
  •                 #Eat something random from the menu 
  •                 action = np.random.randint(0, num_actions, size=1) 
  •             else
  •                 #Choose yourself 
  •                 #q contains the expected rewards for the actions 
  •                 q = model.predict(input_tm1) 
  •                 #We pick the action with the highest expected reward 
  •                 

      推荐阅读

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

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


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

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

  • 关键词: 探索发现

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

    网友点评
    自媒体专栏

    评论

    热度

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