强化学习构建模块库 TRFL

码农软件 · 软件分类 · 机器学习/深度学习 · 2019-08-05 11:42:05

软件介绍

TRFL(发音为“truffle”)建立在 TensorFlow 之上,它是一个强化学习构建模块库。

它是 DeepMind 内部大量用于诸如 DQN、DDPG 和 Importance Weighted Actor Learner Architecture 这些成功的代理如的关键算法组件的集合。

TRFL 库包括实现经典 RL 算法以及更尖端技术的功能,提供的损失函数和其它操作在纯 TensorFlow 中实现。它们不是完整的算法,而是实现了在构建全功能强化学习代理时需要的数学运算。

对于基于值的强化学习,TRFL 提供了 TensorFlow 操作用于在离散动作空间中学习,例如 TD-learning、Sarsa、Q-learning 及其变体,同时也提供了用于实现连续控制算法的操作,例如 DPG。此外 TRFL 还包括用于学习分配值功能的操作。

使用示例

import tensorflow as tf
import trfl

# Q-values for the previous and next timesteps, shape [batch_size, num_actions].
q_tm1 = tf.constant([[1, 1, 0], [1, 2, 0]], dtype=tf.float32)
q_t = tf.constant([[0, 1, 0], [1, 2, 0]], dtype=tf.float32)

# Action indices, pcontinue and rewards, shape [batch_size].
a_tm1 = tf.constant([0, 1], dtype=tf.int32)
pcont_t = tf.constant([0, 1], dtype=tf.float32)
r_t = tf.constant([1, 1], dtype=tf.float32)

loss, q_learning = trfl.qlearning(q_tm1, a_tm1, r_t, pcont_t, q_t)

大多数情况下,您可能只对损失感兴趣:

loss, _ = trfl.qlearning(q_tm1, a_tm1, r_t, pcont_t, q_t)

# You can also do this, which returns the identical `loss` tensor:
loss = trfl.qlearning(q_tm1, a_tm1, r_t, pcont_t, q_t).loss

reduced_loss = tf.reduce_mean(loss)

optimizer = tf.train.AdamOptimizer(learning_rate=0.1)
train_op = optimizer.minimize(reduced_loss)

该模块中的所有损失函数使用上述约定返回损失张量和额外信息。

本文地址:https://www.codercto.com/soft/d/11691.html

反应式设计模式

反应式设计模式

Roland Kuhn、Brian Hanafee、Jamie Allen / 何品、邱嘉和、王石冲、林炜翔审校 / 清华大学出版社 / 2019-1-1 / 98.00 元

《反应式设计模式》介绍反应式应用程序设计的原则、模式和经典实践,讲述如何用断路器模式将运行缓慢的组件与其他组件隔开、如何用事务序列(Saga)模式实现多阶段事务以及如何通过分片模式来划分数据集,分析如何保持源代码的可读性以及系统的可测试性(即使在存在许多潜在交互和失败点的情况下)。 主要内容 ? “反应式宣言”指南 ? 流量控制、有界一致性、容错等模式 ? 得之不易的关于“什么行不通”的经验 ? ......一起来看看 《反应式设计模式》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试