本文整理汇总了Python中pybrain.rl.experiments.EpisodicExperiment.doOptimization方法的典型用法代码示例。如果您正苦于以下问题:Python EpisodicExperiment.doOptimization方法的具体用法?Python EpisodicExperiment.doOptimization怎么用?Python EpisodicExperiment.doOptimization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.rl.experiments.EpisodicExperiment
的用法示例。
在下文中一共展示了EpisodicExperiment.doOptimization方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from pybrain.rl.experiments import EpisodicExperiment [as 别名]
# 或者: from pybrain.rl.experiments.EpisodicExperiment import doOptimization [as 别名]
#.........这里部分代码省略.........
# # switch this to True if you want to see the cart balancing the pole (slower)
# render = False
#
# plt.ion()
#
# env = CartPoleEnvironment()
# if render:
# renderer = CartPoleRenderer()
# env.setRenderer(renderer)
# renderer.start()
#
# module = ActionValueNetwork(4, 3)
#
# task = DiscreteBalanceTask(env, 100)
# learner = NFQ()
# learner.explorer.epsilon = 0.4
#
# agent = LearningAgent(module, learner)
# testagent = LearningAgent(module, None)
# experiment = EpisodicExperiment(task, agent)
#
# performance = []
#
# if not render:
# pf_fig = plt.figure()
count = 0
while(True):
# one learning step after one episode of world-interaction
count += 1
print "learning #",count
experiment.agent = agent
experiment.doOptimization = True
erg = experiment.doEpisodes(1)
print erg
#experiment.doOptimization = False
#print "agent learn"
#agent.learner.learn(1)
if count > 8:
# test performance (these real-world experiences are not used for training)
# if render:
# env.delay = True
#experiment.agent = testagent
print "testing"
experiment.doOptimization = False
erg = experiment.doEpisodes(1)
summe = 0
#print erg
# for x in erg:
# summe = sum(x)
# print summe
#r = mean([sum(x) for x in experiment.doEpisodes(5)])
# env.delay = False
# testagent.reset()
# performance.append(r)
# if not render:
# plotPerformance(performance, pf_fig)
# print "reward avg", r
# print "explorer epsilon", learner.explorer.epsilon
# print "num episodes", agent.history.getNumSequences()