- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在实现 Soft-Actor-Critic 算法,但我无法理解随机策略的工作原理。我在网上搜索过,但没有找到任何有趣的网站可以很好地解释以下实现。我唯一理解的是,在随机策略的情况下,我们将其建模为高斯,并将均值和对数标准差参数化(我认为标准差是标准差),但例如:为什么我们需要对数标准差和不只是标准?
class ActorNetwork(object):
def __init__(self, act_dim, name):
self.act_dim = act_dim
self.name = name
def step(self, obs, log_std_min=-20, log_std_max=2):
with tf.variable_scope(self.name, reuse=tf.AUTO_REUSE):
h1 = tf.layers.dense(obs, 256, tf.nn.relu)
h2 = tf.layers.dense(h1, 256, tf.nn.relu)
mu = tf.layers.dense(h2, self.act_dim, None)
log_std = tf.layers.dense(h2, self.act_dim, tf.tanh)
'''
at the start we could have extremely large values for the log_stds, which could result in some actions
being either entirely deterministic or too random. To protect against that,
we'll constrain the output range of the log_stds, to be within [LOG_STD_MIN, LOG_STD_MAX]
'''
log_std = log_std_min + 0.5 * (log_std_max - log_std_min) * (log_std + 1)
std = tf.exp(log_std)
pi = mu + tf.random_normal(tf.shape(mu)) * std
#gaussian likelihood
pre_sum = -0.5 * (((pi - mu) / (tf.exp(log_std) + EPS)) ** 2 + 2 * log_std + np.log(2 * np.pi))
logp_pi = tf.reduce_sum(pre_sum, axis=1)
mu = tf.tanh(mu)
pi = tf.tanh(pi)
clip_pi = 1 - tf.square(pi) #pi^2
clip_up = tf.cast(clip_pi > 1, tf.float32)
clip_low = tf.cast(clip_pi < 0, tf.float32)
clip_pi = clip_pi + tf.stop_gradient((1 - clip_pi) * clip_up + (0 - clip_pi) * clip_low)
logp_pi -= tf.reduce_sum(tf.log(clip_pi + 1e-6), axis=1)
return mu, pi, logp_pi
def evaluate(self, obs): #Choose action
mu, pi, logp_pi = self.step(obs)
action_scale = 2.0 # env.action_space.high[0]
mu *= action_scale
pi *= action_scale
return mu, pi, logp_pi
最佳答案
你是对的。在高斯策略中,您将观察值(使用策略网络)映射到平均值 mu
和标准差的对数 log_std
操作。这是因为你有一个持续行动的空间。一旦您训练模型在操作空间中分配 mu
和 log_std
,您就可以计算采取由 pi 采样的操作的对数似然。
在高斯策略中,log_std
优于 std
,只是因为 log_std
取 (-inf,+inf) 中的任何值,而 std
仅限于非负值。摆脱这种非负约束可以使训练变得更加容易,而且您也不会因这种转换而丢失任何信息。
关于python - 强化学习如何通过高斯策略进行连续控制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54569726/
下面的脚本 test.php 旨在放置在我所有 wordpress 站点的特定目录中。它的作用是抓取下面$source地址的文件,解压到它所在的目录下。这就是它的全部意图。 例如,我将在我的中央服务器
我有以下代码,并且在 copyMessages() 处遇到资源注入(inject)问题。 我不知道如何解决这个问题? Abstract: Attackers are able to control t
上个学期我介绍了 Java 中的面向对象编程,下学期我将学习 Java 计算机科学 2,它基本上学习用 Java 实现的各种算法和数据结构,例如链表、二叉树等。 ..我可以通过哪些方法来巩固在面向对象
我很好奇 Fortify 规则集在 Android 应用程序中寻找哪些漏洞。不幸的是,我找不到任何相关文件。我知道他们四处寻找 Java 特定的漏洞以及组件的权限检查——还有其他吗? SQL注入(in
我在 fortify 报告中收到第 4 行的 XML 外部实体注入(inject)安全警告。不知道如何解决它。我对 SOAP、JAXB 和 Marshaller 还很陌生。 1 private
查找以“#PermitRootLogin yes”开头的行并替换为“PermitRootLogin no” 在底部添加一行“AllowUsers user1@test.com” 重新启动 sshd 守
我正在尝试强化我的 session 并找到了下面的代码。我的问题是这一行 isset($_SESSION['last_ip']) !== $_SERVER['REMOTE_ADDR']。 当我回显比较
当我在 Java 8 中包含以下代码时,我在 fortify 中遇到 Null Dereference 问题: String name = statusList.stream() .map(s
我有一个强化漏洞:跨站点脚本:DOM。 在我的应用程序(asp.net)中,我们动态构建 html 并将其分配给一个 div 标签,它在其中提示问题。 str += '
强化安全运行不合规代码 public static A read(String path) throws IOException, ClassNotFoundException { try (
出于安全考虑,我计划不允许 Azure 服务与 Azure 服务进行通信,而只允许与它正在使用的服务进行通信。 例如,我有一些使用 Azure SQL 数据库的 Web 应用程序。我应该只在 Azur
出于安全考虑,我计划不允许 Azure 服务与 Azure 服务进行通信,而只允许与它正在使用的服务进行通信。 例如,我有一些使用 Azure SQL 数据库的 Web 应用程序。我应该只在 Azur
早上好,我在 Android 项目上使用 native 库,它只是包签名的简单 md5hash,但是我在具有 JNI 功能的 64 位设备上遇到问题: char *getSignatureMd5(JN
我正在开发一个基于 struts 的 Web 应用程序。在该应用程序中,我们从 Jsp 生成并下载 xls 文件。在Jsp文件和web.xml中,我将内容类型设置为“application/vnd.m
我正在处理遗留系统,我们只是用 HP Fortify 扫描了它并得到了JavaScript Hijacking: Vulnerable Framework,代码如下。我能做些什么来确保这一点?我并不完
大家好,我有一个由 fopen 使用产生的强化问题“路径操作”。根据 fortify,我可以实现一个白名单来修复它,所以有我的白名单验证器: white_list.c #define BUFF_WHI
我们正在使用 Fortify 扫描我的 Android 源代码,但我无法解决这个问题: Category: Android Bad Practices: Missing Google Play Ser
我是一名优秀的程序员,十分优秀!