Ray RLlib User Guides:模型,处理器和动作分布

2023-12-13 16:52

本文主要是介绍Ray RLlib User Guides:模型,处理器和动作分布,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Ray RLlib用户手册地址

默认模型配置设置

在下面的段落中,我们将首先描述RLlib自动构建模型的默认行为(如果您没有设置自定义模型),然后深入了解如何通过更改这些设置或编写自己的模型类来自定义模型。

默认情况下,RLlib将为您的模型使用以下配置设置。其中包括FullyConnectedNetworks(fcnet_hiddens和fcnet_activation)、VisionNetworks(conv_filters和conv_activation)、自动RNN包装、自动注意力(GTrXL)包装以及Atari环境的一些特殊选项:

MODEL_DEFAULTS: ModelConfigDict = {# 实验性标志# 如果为True,则用户指定不要创建的预处理器# (通过 config._disable_preprocessor_api=True)。如果为 True,则观察结果将在环境返回时直接到达模型中"_disable_preprocessor_api": False,# 实验性标志# If True, RLlib will no longer flatten the policy-computed actions into# a single tensor (for storage in SampleCollectors/output files/etc..),# but leave (possibly nested) actions as-is. Disabling flattening affects:# - SampleCollectors:必须存储可能嵌套的操作结构。# - 将之前的action作为其输入的一部分的模型。# - 从脱机文件读取的算法(包括操作信息)。"_disable_action_flattening": False,# === 内置选项 ===# 全连接网络 (tf and torch): rllib.models.tf|torch.fcnet.py# 如果未指定自定义模型并且输入空间为1D,则使用这个模型.# Number of hidden layers to be used."fcnet_hiddens": [256, 256],# 激活函数描述符# Supported values are: "tanh", "relu", "swish" (or "silu", which is the same),# "linear" (or None)."fcnet_activation": "tanh",# 视觉网络 (tf and torch): rllib.models.tf|torch.visionnet.py# 如果未指定自定义模型并且输入空间为2D,则使用这些# 过滤器配置:每个过滤器的[out_channels,内核,步幅]列表# Example:# Use None for making RLlib try to find a default filter setup given the# observation space."conv_filters": None,# Activation function descriptor.# Supported values are: "tanh", "relu", "swish" (or "silu", which is the same),# "linear" (or None)."conv_activation": "relu",# 一些默认模型支持具有给定激活的 n 个密集层的最终 FC 堆栈:# - Complex observation spaces: Image components are fed through#   VisionNets, flat Boxes are left as-is, Discrete are one-hot'd, then#   everything is concated and pushed through this final FC stack.# - VisionNets (CNNs), e.g. after the CNN stack, there may be#   additional Dense layers.# - FullyConnectedNetworks will have this additional FCStack as well# (that's why it's empty by default)."post_fcnet_hiddens": [],"post_fcnet_activation": "relu",# 对于 DiagGaussian 动作分布,使模型的后半部分输出浮动偏差变量而不是状态相关变量。# 这仅在使用默认的全连接网络时有效。"free_log_std": False,# Whether to skip the final linear layer used to resize the hidden layer# outputs to size `num_outputs`. If True, then the last hidden layer# should already match num_outputs."no_final_linear": False,# Whether layers should be shared for the value function."vf_share_layers": True,# == LSTM ==# 是否用LSTM包装模型。"use_lstm": False,# Max seq len for training the LSTM, defaults to 20."max_seq_len": 20,# Size of the LSTM cell."lstm_cell_size": 256,# Whether to feed a_{t-1} to LSTM (one-hot encoded if discrete)."lstm_use_prev_action": False,# Whether to feed r_{t-1} to LSTM."lstm_use_prev_reward": False,# Whether the LSTM is time-major (TxBx..) or batch-major (BxTx..)."_time_major": False,# == 注意力网络(transformer) (experimental: torch-version is untested) ==# 是否使用 GTrXL ("Gru transformer XL"; attention net) as the# wrapper Model around the default Model."use_attention": False,# The number of transformer units within GTrXL.# A transformer unit in GTrXL consists of a) MultiHeadAttention module and# b) a position-wise MLP."attention_num_transformer_units": 1,# The input and output size of each transformer unit."attention_dim": 64,# The number of attention heads within the MultiHeadAttention units."attention_num_heads": 1,# The dim of a single head (within the MultiHeadAttention units)."attention_head_dim": 32,# The memory sizes for inference and training."attention_memory_inference": 50,"attention_memory_training": 50,# The output dim of the position-wise MLP."attention_position_wise_mlp_dim": 32,# The initial bias values for the 2 GRU gates within a transformer unit."attention_init_gru_gate_bias": 2.0,# Whether to feed a_{t-n:t-1} to GTrXL (one-hot encoded if discrete)."attention_use_n_prev_actions": 0,# Whether to feed r_{t-n:t-1} to GTrXL."attention_use_n_prev_rewards": 0,# == Atari ==# Set to True to enable 4x stacking behavior."framestack": True,# Final resized frame dimension"dim": 84,# (deprecated) Converts ATARI frame to 1 Channel Grayscale image"grayscale": False,# (deprecated) Changes frame to range from [-1, 1] if true"zero_mean": True,# === 自定义模型的选项 ===# Name of a custom model to use"custom_model": None,# Extra options to pass to the custom classes. These will be available to# the Model's constructor in the model_config field. Also, they will be# attempted to be passed as **kwargs to ModelV2 models. For an example,# see rllib/models/[tf|torch]/attention_net.py."custom_model_config": {},# Name of a custom action distribution to use."custom_action_dist": None,# Custom preprocessors are deprecated. Please use a wrapper class around# your environment instead to preprocess observations."custom_preprocessor": None,# === RLModules中ModelConfigs的选项 ===# 要编码的潜在维度。# Since most RLModules have an encoder and heads, this establishes an agreement# on the dimensionality of the latent space they share.# This has no effect for models outside RLModule.# If None, model_config['fcnet_hiddens'][-1] value will be used to guarantee# backward compatibility to old configs. This yields different models than past# versions of RLlib."encoder_latent_dim": None,# Whether to always check the inputs and outputs of RLlib's default models for# their specifications. Input specifications are checked on failed forward passes# of the models regardless of this flag. If this flag is set to `True`, inputs and# outputs are checked on every call. This leads to a slow-down and should only be# used for debugging. Note that this flag is only relevant for instances of# RLlib's Model class. These are commonly generated from ModelConfigs in RLModules."always_check_shapes": False,# Deprecated keys:# Use `lstm_use_prev_action` or `lstm_use_prev_reward` instead."lstm_use_prev_action_reward": DEPRECATED_VALUE,# Deprecated in anticipation of RLModules API"_use_default_native_models": DEPRECATED_VALUE,}

内置模型

在对原始环境输出进行预处理(如果适用)后,处理后的观察结果将通过策略的模型提供。如果没有指定自定义模型(请参阅下面关于如何自定义模型的进一步信息),RLlib将根据简单的启发式方法选择一个默认模型:

  1. 用于形状长度大于 2 的观察的视觉网络(TF 或 Torch),例如 (84 x 84 x 3)。
  2. 用于其他一切的完全连接的网络(TF 或 Torch)。

这些默认模型类型可以通过算法配置中的模型配置键进一步配置(如上所述)。上面列出了可用的设置,模型目录文件中也记录了这些设置。

请注意,对于视觉网络情况,如果您的环境观察具有自定义大小,则可能必须配置conv_Filters。例如,对于42x42观测值,\“MODEL\”:{\“DIM\”:42,\“CONV_FILTIRS\”:[[16,[4,4],2],[32,[4,4],2],[512,[11,11],1]]}。因此,请始终确保最后一个Conv2D输出的输出形状为B,1,1,X,其中B=批处理,X=最后一个Conv2D层的滤镜数量,以便RLlib可以将其展平。如果不是这样,将抛出信息性错误。

内置自动LSTM和自动注意包装

此外,如果在模型配置中设置了 “use_lstm”: True 或 “use_attention”: True ,则模型的输出将分别由LSTM单元(TF或Torch)或注意(GTrXL)网络(TF或Torch)进一步处理。更广泛地说,RLlib支持对其所有策略梯度算法(A3C、PPO、PG、Impala)使用重复/注意模型,并且在其策略评估实用程序中内置了必要的序列处理支持。

关于使用哪些附加配置键来更详细地配置这两个自动包装器的详细信息,请参见上面的内容(例如,您可以通过lstm_cell_size指定LSTM层的大小,或者通过attence_dim指定注意暗度)。

对于完全定制的 RNN / LSTM / Attention-Net 设置,请参阅下面的循环模型和注意网络/Transformers 部分。

这篇关于Ray RLlib User Guides:模型,处理器和动作分布的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/489196

相关文章

大模型研发全揭秘:客服工单数据标注的完整攻略

在人工智能(AI)领域,数据标注是模型训练过程中至关重要的一步。无论你是新手还是有经验的从业者,掌握数据标注的技术细节和常见问题的解决方案都能为你的AI项目增添不少价值。在电信运营商的客服系统中,工单数据是客户问题和解决方案的重要记录。通过对这些工单数据进行有效标注,不仅能够帮助提升客服自动化系统的智能化水平,还能优化客户服务流程,提高客户满意度。本文将详细介绍如何在电信运营商客服工单的背景下进行

Andrej Karpathy最新采访:认知核心模型10亿参数就够了,AI会打破教育不公的僵局

夕小瑶科技说 原创  作者 | 海野 AI圈子的红人,AI大神Andrej Karpathy,曾是OpenAI联合创始人之一,特斯拉AI总监。上一次的动态是官宣创办一家名为 Eureka Labs 的人工智能+教育公司 ,宣布将长期致力于AI原生教育。 近日,Andrej Karpathy接受了No Priors(投资博客)的采访,与硅谷知名投资人 Sara Guo 和 Elad G

Retrieval-based-Voice-Conversion-WebUI模型构建指南

一、模型介绍 Retrieval-based-Voice-Conversion-WebUI(简称 RVC)模型是一个基于 VITS(Variational Inference with adversarial learning for end-to-end Text-to-Speech)的简单易用的语音转换框架。 具有以下特点 简单易用:RVC 模型通过简单易用的网页界面,使得用户无需深入了

透彻!驯服大型语言模型(LLMs)的五种方法,及具体方法选择思路

引言 随着时间的发展,大型语言模型不再停留在演示阶段而是逐步面向生产系统的应用,随着人们期望的不断增加,目标也发生了巨大的变化。在短短的几个月的时间里,人们对大模型的认识已经从对其zero-shot能力感到惊讶,转变为考虑改进模型质量、提高模型可用性。 「大语言模型(LLMs)其实就是利用高容量的模型架构(例如Transformer)对海量的、多种多样的数据分布进行建模得到,它包含了大量的先验

图神经网络模型介绍(1)

我们将图神经网络分为基于谱域的模型和基于空域的模型,并按照发展顺序详解每个类别中的重要模型。 1.1基于谱域的图神经网络         谱域上的图卷积在图学习迈向深度学习的发展历程中起到了关键的作用。本节主要介绍三个具有代表性的谱域图神经网络:谱图卷积网络、切比雪夫网络和图卷积网络。 (1)谱图卷积网络 卷积定理:函数卷积的傅里叶变换是函数傅里叶变换的乘积,即F{f*g}

秋招最新大模型算法面试,熬夜都要肝完它

💥大家在面试大模型LLM这个板块的时候,不知道面试完会不会复盘、总结,做笔记的习惯,这份大模型算法岗面试八股笔记也帮助不少人拿到过offer ✨对于面试大模型算法工程师会有一定的帮助,都附有完整答案,熬夜也要看完,祝大家一臂之力 这份《大模型算法工程师面试题》已经上传CSDN,还有完整版的大模型 AI 学习资料,朋友们如果需要可以微信扫描下方CSDN官方认证二维码免费领取【保证100%免费

【生成模型系列(初级)】嵌入(Embedding)方程——自然语言处理的数学灵魂【通俗理解】

【通俗理解】嵌入(Embedding)方程——自然语言处理的数学灵魂 关键词提炼 #嵌入方程 #自然语言处理 #词向量 #机器学习 #神经网络 #向量空间模型 #Siri #Google翻译 #AlexNet 第一节:嵌入方程的类比与核心概念【尽可能通俗】 嵌入方程可以被看作是自然语言处理中的“翻译机”,它将文本中的单词或短语转换成计算机能够理解的数学形式,即向量。 正如翻译机将一种语言

AI Toolkit + H100 GPU,一小时内微调最新热门文生图模型 FLUX

上个月,FLUX 席卷了互联网,这并非没有原因。他们声称优于 DALLE 3、Ideogram 和 Stable Diffusion 3 等模型,而这一点已被证明是有依据的。随着越来越多的流行图像生成工具(如 Stable Diffusion Web UI Forge 和 ComyUI)开始支持这些模型,FLUX 在 Stable Diffusion 领域的扩展将会持续下去。 自 FLU

SWAP作物生长模型安装教程、数据制备、敏感性分析、气候变化影响、R模型敏感性分析与贝叶斯优化、Fortran源代码分析、气候数据降尺度与变化影响分析

查看原文>>>全流程SWAP农业模型数据制备、敏感性分析及气候变化影响实践技术应用 SWAP模型是由荷兰瓦赫宁根大学开发的先进农作物模型,它综合考虑了土壤-水分-大气以及植被间的相互作用;是一种描述作物生长过程的一种机理性作物生长模型。它不但运用Richard方程,使其能够精确的模拟土壤中水分的运动,而且耦合了WOFOST作物模型使作物的生长描述更为科学。 本文让更多的科研人员和农业工作者

线性因子模型 - 独立分量分析(ICA)篇

序言 线性因子模型是数据分析与机器学习中的一类重要模型,它们通过引入潜变量( latent variables \text{latent variables} latent variables)来更好地表征数据。其中,独立分量分析( ICA \text{ICA} ICA)作为线性因子模型的一种,以其独特的视角和广泛的应用领域而备受关注。 ICA \text{ICA} ICA旨在将观察到的复杂信号