本文整理汇总了Python中Model.Model.backward_sarsa_control方法的典型用法代码示例。如果您正苦于以下问题:Python Model.backward_sarsa_control方法的具体用法?Python Model.backward_sarsa_control怎么用?Python Model.backward_sarsa_control使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.backward_sarsa_control方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Model
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import backward_sarsa_control [as 别名]
from Model import Model
model = Model(100)
model.backward_sarsa_control(1000, 0.1)
model.dump_states("0.1sarsa_result.json")
model.surface_plot()
示例2: range
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import backward_sarsa_control [as 别名]
from Model import Model
import numpy as np
import json
mse = np.zeros(11)
for l in range(11):
model_mc = Model(100)
model_mc.mc_control(1000000)
model_sarsa = Model(100)
model_sarsa.backward_sarsa_control(100000, l/10.0)
#mse_hit = np.arange(210, dtype = np.float32).reshape(10, 21)
#mse_stick = np.arange(210, dtype = np.float32).reshape(10, 21)
#mse = {"hit": mse_hit, "stick": mse_stick}
for i in range(10):
for j in range(21):
for action in model_mc.states[i][j].action_value_function:
mse[l] += ((model_sarsa.states[i][j].action_value_function[action] -
model_mc.states[i][j].action_value_function[action]) ** 2)
with open("mean_square_error", 'w') as outfile:
for i in range(11):
outfile.write("lambda=" + str(i/10.0) + ": ")
json.dump(mse[i], outfile)
outfile.write("\n")