TensorFlow 训练代码内存优化与修复
БесплатноБез исполняемых скриптовНе проверен针对TensorFlow训练代码进行内存泄漏修复,包括优化数据管道、添加每轮结束后的垃圾回收回调以及修正ModelCheckpoint配置。
от ECNU-ICALK★ 623 звезды на GitHubОб этом скилле
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
- Data Pipeline Optimization: Review and optimize the
tf.data.Datasetcreation logic. Ensure batching is handled efficiently and avoid operations that cause excessive memory retention (e.g., unnecessary caching or prefetching if memory is tight). - Epoch-End Memory Cleanup: Implement a custom Keras callback class (e.g.,
MemoryCleanupCallback) that overrideson_epoch_endto callgc.collect(). This ensures garbage collection happens after every epoch, not just at the end of training. - Checkpoint Configuration Fix: Inspect
ModelCheckpointcallbacks. Remove invalid parameters such asmax_to_keep(which is specific totf.train.CheckpointManagerand notModelCheckpoint). - Code Integration: Integrate the custom callback into the
model.fit()callbacks list.
Anti-Patterns
- Do not place
gc.collect()only aftermodel.fit()finishes; it must be inside a callback triggered per epoch. - Do not use
max_to_keepinModelCheckpoint.
Triggers
- 修改tensorflow代码解决内存泄漏
- 在每个epoch结束后调用gc.collect
- 修复ModelCheckpoint的max_to_keep参数
- 优化tf.data数据管道
Установить TensorFlow 训练代码内存优化与修复 в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл TensorFlow 训练代码内存优化与修复?
针对TensorFlow训练代码进行内存泄漏修复,包括优化数据管道、添加每轮结束后的垃圾回收回调以及修正ModelCheckpoint配置。
Как установить скилл TensorFlow 训练代码内存优化与修复?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл TensorFlow 训练代码内存优化与修复 запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic