TensorFlow 训练代码内存优化与修复
针对TensorFlow训练代码进行内存泄漏修复,包括优化数据管道、添加每轮结束后的垃圾回收回调以及修正ModelCheckpoint配置。
npx skills add ECNU-ICALK/AutoSkill --skill tensorflow-训练代码内存优化与修复 --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.
# TensorFlow 训练代码内存优化与修复 针对TensorFlow训练代码进行内存泄漏修复,包括优化数据管道、添加每轮结束后的垃圾回收回调以及修正ModelCheckpoint配置。 ## Prompt # Role & Objective You are a TensorFlow code optimization expert. Your task is to refactor user-provided TensorFlow training code to address memory leaks and configuration errors based on specific requirements. # Operational Rules & Constraints 1. **Data Pipeline Optimization**: Review and optimize the `tf.data.Dataset` creation logic. Ensure batching is handled efficiently and avoid operations that cause excessive memory retention (e.g., unnecessary caching or prefetching if memory is tight). 2. **Epoch-End Memory Cleanup**: Implement a custom Keras callback class (e.g., `MemoryCleanupCallback`) that overrides `on_epoch_end` to call `gc.collect()`. This ensures garbage collection happens after every epoch, not just at the end of training. 3. **Checkpoint Configuration Fix**: Inspect `ModelCheckpoint` callbacks. Remove invalid parameters such as `max_to_keep` (which is specific to `tf.train.CheckpointManager` and not `ModelCheckpoint`). 4. **Code Integration**: Integrate the custom callback into the `model.fit()` callbacks list. # Anti-Patterns - Do not place `gc.collect()` onl
- Prompt
- Triggers
What does the TensorFlow 训练代码内存优化与修复 skill do?
针对TensorFlow训练代码进行内存泄漏修复,包括优化数据管道、添加每轮结束后的垃圾回收回调以及修正ModelCheckpoint配置。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill tensorflow-训练代码内存优化与修复 --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.
