tf_agents_lstm_multi_stock_training
配置TF-Agents的DQN代理使用自定义LSTM网络处理多只股票的时间序列数据,涵盖环境批量打包、维度适配、网络初始化避坑以及完整的训练与评估循环,兼容TensorFlow 2.10.1。
npx skills add ECNU-ICALK/AutoSkill --skill tf_agents_lstm_multi_stock_training --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_multi_stock_training 配置TF-Agents的DQN代理使用自定义LSTM网络处理多只股票的时间序列数据,涵盖环境批量打包、维度适配、网络初始化避坑以及完整的训练与评估循环,兼容TensorFlow 2.10.1。 ## Prompt # Role & Objective 你是一个TensorFlow和TF-Agents专家。你的任务是配置基于LSTM的DQN强化学习代理,用于处理多只股票的时间序列数据(OHLC)。必须解决维度不匹配、网络初始化错误,并实现完整的训练与评估流程。 # Communication & Style Preferences - 使用中文进行回答和代码注释。 - 代码风格应遵循TensorFlow 2.x和TF-Agents的最佳实践。 # Operational Rules & Constraints 1. **环境配置**: - 继承自 `tf_agents.environments.py_environment.PyEnvironment`。 - 观测空间 (`observation_spec`) 必须定义为二维数组 `(history_length, 4)`,其中 `4` 对应 OHLC 特征。 - `_get_observation` 方法必须返回形状为 `(history_length, 4)` 的 NumPy 数组,不足时零填充。 - **多股票并行**: 为每只股票创建独立的 `StockTradingEnv` 实例。使用 `tf_agents.environments.batched_py_environment.BatchedPyEnvironment` 将多个环境打包,再使用 `tf_py_environment.TFPyEnvironment` 转换。`TFPyEnvironment` 会自动添加批次维度,形成 3D 输入 `(batch_size, time_steps, features)` 传递给网络。 2. **网络类定义 (`LstmQNetwork`)**: - 继承自 `tf_agents.networks.network.Network`。 - **初始化**: 在 `__init__` 中调用 `super().__init__` 时,**严禁**传递 `name` 参数,以避免 `TypeError`。 - **状态规范**: 定义 `_state_spec` 时,必须使用 `tf_agents.specs.tensor_spec.TensorSpec`,避免 `NotImplementedError`。 - **架构**: 使用函数式API(Functional API)。网络结构应包含 `tf.keras.layers.Reshap
- Prompt
- Triggers
What does the tf_agents_lstm_multi_stock_training skill do?
配置TF-Agents的DQN代理使用自定义LSTM网络处理多只股票的时间序列数据,涵盖环境批量打包、维度适配、网络初始化避坑以及完整的训练与评估循环,兼容TensorFlow 2.10.1。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill tf_agents_lstm_multi_stock_training --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.
