本文整理汇总了Python中Helper.Helper.getSaveName方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.getSaveName方法的具体用法?Python Helper.getSaveName怎么用?Python Helper.getSaveName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helper.Helper
的用法示例。
在下文中一共展示了Helper.getSaveName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: learn
# 需要导入模块: from Helper import Helper [as 别名]
# 或者: from Helper.Helper import getSaveName [as 别名]
def learn(self, savePrefix, numSampleIt, continueLearning = True,
numLearnIt = 1, startEpsilon = 0.0, epsilonFactor = 1.0):
""" sampling """
self.objectShape = 'quad'
self.numKilobots = 4
self.numEpisodes = 25
self.numStepsPerEpisode = 100
self.stepsPerSec = 4096
self.sDim = self.NUM_NON_KB_DIM + 2 * self.numKilobots
if continueLearning:
# dont reset sample or policy
if self.S is None:
self.S, self.A, self.R, self.S_ = empty((0, self.sDim)),\
empty((0, 2)), empty((0, 1)), empty((0, self.sDim))
else:
# reset samples, policy and number of iterations
self.S, self.A, self.R, self.S_ = empty((0, self.sDim)),\
empty((0, 2)), empty((0, 1)), empty((0, self.sDim))
self.policy = SparseGPPolicy(KilobotKernel(self.NUM_NON_KB_DIM),
self.aRange)
self.it = 0
""" LSTD """
self.lstd.discountFactor = 0.99
factor = 1.0
factorKb = 1.0
weightNonKb = 0.5
self.bwFactorNonKbSA = factor
self.bwFactorKbSA = factorKb
self.weightNonKbSA = weightNonKb
self.bwFactorNonKbS = factor
self.bwFactorKbS = factorKb
self.weightNonKbS = weightNonKb
self.numFeatures = 200
""" REPS """
self.reps.epsilonAction = 0.5
""" GP """
self.policy.GPMinVariance = 0.0
self.policy.GPRegularizer = 0.05
self.numSamplesSubsetGP = 200
self.bwFactorNonKbGP = factor
self.bwFactorKbGP = factorKb
self.weightNonKbGP = weightNonKb
self.numLearnIt = numLearnIt
self.startEpsilon = startEpsilon
self.epsilon = startEpsilon
self.epsilonFactor = epsilonFactor
# make data dir and save params
if savePrefix == '':
savePath = ''
else:
savePath = os.path.join(savePrefix, Helper.getSaveName())
os.makedirs(savePath)
self.saveParams(os.path.join(savePath, 'params'))
rewards = []
for i in range(numSampleIt):
t = time.time()
# get new samples
St, At, Rt, S_t = self._getSamples()
print('sum reward for last samples: {}'.format(Rt.sum()))
rewards += [Rt.sum()]
# add samples
self.S = r_[self.S, St]
self.A = r_[self.A, At]
self.R = r_[self.R, Rt]
self.S_ = r_[self.S_, S_t]
# only keep 10000 samples
SARS = c_[self.S, self.A, self.R, self.S_]
SARS = Helper.getRandomSubset(SARS, 10000)
self.S, self.A, self.R, self.S_ = self._unpackSARS(SARS)
self._updateKernelParameters(self.S, self.A, random=True,
normalize=True)
self.PHI_S = self.kernelS.getGramMatrix(self.S, self.MuS)
#.........这里部分代码省略.........