avatar
Articles
103
Tags
32
Categories
26

Home
Archives
Tags
Categories
Link
About
detect
Search
Home
Archives
Tags
Categories
Link
About

detect

SAC
Created2024-03-25|RL
SAC detect0530@gmail.com Problem to be solved policy梯度那里,Z为什么能忽略。以及梯度加法那里。(泛函杀我) SQL数学上和SAC区别 SAC’s background SAC主要解决的是连续动作空间的控制问题,在我们一探SAC究竟之前,让我们先回顾SAC之前解决连续动作控制问题的两个主流算法:DDPG,PPO。 DDPG DDPG是基于DPG(Deterministic Policy Gradient)的算法,我们接着先从DPG说起。 DPG 引入AC(actor - critic)框架,让值函数直接指导策略优化。这里有必要提一下,是因为DPG与之前的PG算法有本质的不同: 过去的PG算法使用累计收益(需要真的去模拟,做蒙特卡洛估计)作为目标,调整策略以追求更高的收益。 而DPG则是利用critic(Q函数)找到可能得最优策略,随后直接依靠Q值去优化策略函数,也就是说策略的调整完全不用依靠实际收益。 DPG的核心公式: max⁡θEs∼D[Qωμ(s,μθ(s))]\max_{\theta}\mathbb{E ...
tensorboard
Created2024-03-18|python
Tensorboard 详细的介绍和常见报错可以参考 TensorBoard最全使用教程:看这篇就够了 Tensorboard 无法打开网页 /不显示数据 / 命令行报错等解决办法集合 导入库 tensorboard是tensorflow的可视化工具,可以用来查看模型的训练过程,模型结构,模型参数等。 但是现在pytorch也支持tensorboard了,在处理loss,acc等数据的时候,可以使用tensorboard来可视化。 使用方法 123456# 生成一个writer对象,并指定生成图片的目录,其中logs为指定生成事件的目录writer = SummaryWriter("logs")for i in range(100): # 以y=x为标题,i为横坐标值,i同时也为纵坐标值,相当于绘制了一个y=x(0<=x<100)的直线 writer.add_scalar("y=x",i,i)writer.close() 运行代码之后会生成一个指定名字的目录,并且会包含一个事件在里面,这个事件要用tensorb ...
ArgumentParser
Created2024-03-18|python
ArgumentParser 更具体细节的讲解可以参考知乎_Link 创建parser 12import argparseparser = argparse.ArgumentParser("Hyperparameters Setting for PPO-continuous") 创建parser对象,可以传入一个字符串作为描述信息。 添加参数 123parser.add_argument("--max_train_steps", type=int, default=int(3e6), help=" Maximum number of training steps")parser.add_argument("--evaluate_freq", type=float, default=5e3, help="Evaluate the policy every 'evaluate_freq' steps")parser.add_argument("--pol ...
Python Grammar
Created2024-03-18|python
Python 1D = collections.defaultdict(list) 创建一个默认映射到list的字典。(帮助避免了很多意外情况) 12op,l,r,y,z = map(int,input().split())t = ''.join(input().split(" ")) 很方便的处理一行的输出,split()默认跳过空白字符。 将输入拼成一个字符串,方便处理。 1a.sort(key=lambda x:x.r) 对a本生进行排序,这里有key函数:按照key=(比较函数),进行比较。比较函数,可以很方便的用lambda来表示。 如果想反过来排序,可以用reverse=True参数。 1print("{0} - > {1}".format(i.l,i.r),end="\n") 格式化输出,这里的0和1是format函数的参数,可以用来指定输出的位置。同时python print自带换行,如果不想换行可以自定义end参数 ...
PPO code experiment
Created2024-03-14|RL
PPO code experiment detect0530@gmail.com This is a simple experiment to test the PPO algorithm on the OpenAI gym environment. All code resource is from the repository: Link1, which is also inspired by a blog paper from 37 PPO Tricks. Here, I’d like to split the code frame, and note what I have learned from the code. Code Frame main argparse, set the hyperparameter tensorboard, log the training process evaluate policy, test the policy train policy, train the policy ppo_agent Actor Mod ...
RL_toolbox
Created2024-03-14
Proximal Policy Optimization(PPO)
Created2024-03-14|RL
Proximal Policy Optimization(PPO) detect0530@gmail.com Background: PG and TRPO Policy Gradient 我们使用策略网络进行决策,对于每一版的policy network,我们使用on-policy的方法获得数据,并使用这些数据更新网络,得到下一版的policy network。 更新过程其实就是根据Reward来调整给每一个action分配的权重。 Tips: 增加一个基线 原始算法我们用reward的大小作为引导,但是reward设计的不好时,由于采取动作都会有奖励,一是有noise,二是这样引导会错过一些未访问过的good action。于是我们引入基线(一般设置为V(s),表示所有采样序列的平均奖励),高于基线,给正奖励;低于基线,给负奖励。 折扣因子 降低未来reward的权重,只需要对奖励序列的求和计算增加一个gamma因子即可。 优势函数 回顾之前的算法,对于一个采样序列中的数据点,我们都是用相同的R(γ)R(\gamma)R(γ)作为系数,这样很粗糙。实际上好 ...
DDPG
Created2024-03-06|RL
Deep Deterministic Policy Gradient Background 在过去的DQN实践中,我们更多的采用神经网络直接对状态s进行近似,映射分数到动作空间里然后再根据得分选择动作。这种方法在离散动作空间中表现良好,但是在连续动作空间中表现不佳。因为在连续动作空间中,动作空间的维度很高,而且动作空间的连续性使得我们无法直接使用神经网络来近似动作空间。因此,我们需要一种新的方法来解决这个问题。 Quick Facts DDPG is an off-policy algorithm. DDPG can only be used for environments with continuous action spaces. DDPG can be thought of as being deep Q-learning for continuous action spaces. Key Equations 我们从两个角度理解DDSG,一个是Q-learning的角度,另一个是策略梯度的角度。 Q-learning角度 L(ϕ,D)=E(s,a,r,s′,d)∼P[( ...
Dueling-DQN
Created2024-02-29|RL
Dueling DQN Abstract 我们评估两个东西,一个是状态价值,一个是动作优势函数。在动作价值接近的时候,会很work。 为什么要采用对偶网络结构? 其实动机很简单:很多游戏的Q值,只受当前状态影响,无论采取什么动作区别不大。如下图所示: 这是Atari game中的一个赛车游戏,Value表示状态价值,Advantage表示动作优势值,图中黄色部分表示注意力。当前方没有车辆时,智能体左右移动并没有影响,说明动作对Q值没有影响,但是状态对Q值很有影响。从上面两幅图可以看出,Value更加关注远方道路,因为开的越远,对应的状态值越大;Advantage没有特别注意的地方,说明动作没有影响。当前方存在车辆阻挡时,智能体的动作选择至关重要,说明动作对Q值存在影响,同样状态对Q值也会存在影响。从下面两幅图可以看出,Value同样更加关注远方道路,但是Advantge此时会关注前方车辆,因为如果不采取相应动作,智能体很有可能会发生碰撞,分数就会很低。对偶网络思想符合很多场景的设定。 可以看到,状态函数和价值函数关注的是不一样的东西。 定义优势函数: Aπ=Qπ(s,a)−V ...
Prioritized Experience Replay
Created2024-02-29|RL
Prioritized Experience Replay Experience replay的演化 online RL:缺点:经验之间是correlated的,不满足stochastic gradient-decent的要求。另外,有用的好经验被使用一次后就遗忘了。 普通的experience replay可以记下经验,然后抽样更新参数,这样一方面减少了对打量经验的需求,转而用更多的计算力和内存(经常比RL agent和环境交互更cheaper) 而Prioritized experience replay further liberates the agents from considering transitions with the same frequency that they are experienced. 一些tricks 总的来说,用TD error来衡量经验的重要性,但是这样有两个问题: (a) loss of diversity,影响stochastic gradient descent的性能。 (b) introduce bias,需要我们用impor ...
1…456…11
avatar
Richard
If you can't explain it simply, you don't understand it well enough.
Articles
103
Tags
32
Categories
26
Follow Me
Announcement
blog is buliding!
Recent Post
Math Guide2025-06-28
Positional Encoding2025-06-26
Auto-encoder2025-06-09
矩阵计算2025-06-09
好运设计2025-05-30
JAX base2025-05-06
Python Multiprocess2025-05-05
C++ Embedding Python2025-05-05
Python tips2025-05-01
Pandas Tips2025-05-01
Categories
  • DL17
    • Lee's HW1
    • Lee's notes15
    • code1
  • Math1
    • Bayesian Network and MCMC1
  • NJU course11
    • Crypto1
Tags
实验报告 实习 nju linux LLM catalog GAN tool python hexo resume mathbb ml math c++ ML algorithm git 随笔 OS 神经网络 diffusion DS HW GPT paper Metabit 机器学习 RL Quant note vim
Archives
  • June 20254
  • May 20256
  • March 202510
  • February 20252
  • January 20256
  • October 20245
  • June 20241
  • May 20243
  • April 20243
  • March 20248
  • February 20246
  • January 202416
  • December 20238
  • November 20237
  • October 20233
  • September 20237
  • July 20233
  • June 20234
  • March 20231
Info
Article :
103
Run time :
Total Count :
267.1k
Last Push :
©2020 - 2025 By Richard
Framework Hexo|Theme Butterfly
Search
Loading the Database