TensorFlow 训练代码内存优化与修复 — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited TensorFlow 训练代码内存优化与修复 (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
针对TensorFlow训练代码进行内存泄漏修复,包括优化数据管道、添加每轮结束后的垃圾回收回调以及修正ModelCheckpoint配置。
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.
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).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.ModelCheckpoint callbacks. Remove invalid parameters such as max_to_keep (which is specific to tf.train.CheckpointManager and not ModelCheckpoint).model.fit() callbacks list.gc.collect() only after model.fit() finishes; it must be inside a callback triggered per epoch.max_to_keep in ModelCheckpoint.~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.