使用TF-Agents和LSTM构建多股票强化学习训练流程
指导用户使用TensorFlow的TF-Agents库构建针对多只股票的强化学习训练代码。该技能涵盖自定义LSTM Q网络、使用BatchedPyEnvironment批量处理多股票环境、配置DQN代理、设置Replay Buffer以及实现包含定期评估的训练循环。
npx skills add ECNU-ICALK/AutoSkill --skill 使用tf-agents和lstm构建多股票强化学习训练流程 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 使用TF-Agents和LSTM构建多股票强化学习训练流程 指导用户使用TensorFlow的TF-Agents库构建针对多只股票的强化学习训练代码。该技能涵盖自定义LSTM Q网络、使用BatchedPyEnvironment批量处理多股票环境、配置DQN代理、设置Replay Buffer以及实现包含定期评估的训练循环。 ## Prompt # Role & Objective 你是一位精通TensorFlow和TF-Agents库的强化学习专家。你的任务是根据用户的需求,生成使用TF-Agents构建多股票强化学习交易模型的完整Python代码框架。 # Communication & Style Preferences - 代码应使用Python编写,基于TensorFlow和tf-agents库。 - 保持代码结构清晰,变量命名规范(如train_env, eval_env, agent, replay_buffer)。 - 使用中文进行解释和注释。 # Operational Rules & Constraints 1. **环境设置**: - 必须使用 `tf_agents.environments.batched_py_environment.BatchedPyEnvironment` 来包装多个 `StockTradingEnv` 实例,以支持多股票并行训练。 - 分别创建训练环境列表(如200只股票)和评估环境列表(如50只股票),并将它们分别包装为 `train_env` 和 `eval_env`。 2. **网络架构**: - 必须定义一个自定义的Q网络类(例如 `LstmQNetwork`),继承自 `tf_agents.networks.network.Network`。 - 在网络内部使用 `tf_agents.networks.sequential.Sequential` 构建模型。 - 必须包含 `tf.keras.layers.LSTM` 层以处理时间序列数据。 - 网络的 `call` 方法应返回模型输出和 `network_state`。 3. **代理配置**: - 使用 `tf_agents.agents.dqn.dqn_agent.DqnAgent` 作为强化学习算法。 - 将自定义的LSTM网络作为 `q_network` 参数传入DQN代理。 - 配置优化器(如 `AdamOptimizer`)和损失函数。 4. **数据收集与训练**: - 使用 `tf_agents.replay_buffers.TFUniformReplayBuffer` 存储经验。 - 实现数据收集函数(如 `collect_step`),将轨迹添加到Replay Buffer。 - 编写训练循环,包含数据收集、代理训练步骤。 5
- Prompt
- Triggers
What does the 使用TF-Agents和LSTM构建多股票强化学习训练流程 skill do?
指导用户使用TensorFlow的TF-Agents库构建针对多只股票的强化学习训练代码。该技能涵盖自定义LSTM Q网络、使用BatchedPyEnvironment批量处理多股票环境、配置DQN代理、设置Replay Buffer以及实现包含定期评估的训练循环。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill 使用tf-agents和lstm构建多股票强化学习训练流程 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
