tensorflow-project-template
Guides agents in adapting TensorFlow Project Template training-project structure, configs, models, trainers, data loaders, TensorBoard logging, checkpoints, and safe smoke checks.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- tensorflow-project-template
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Guides agents in adapting TensorFlow Project Template training-project structure, configs, models, trainers, data loaders, TensorBoard logging, checkpoints, and safe smoke checks.
- disable-model-invocation
- true
02 资源文件 8
- 参考文档references/api-reference.md7.3 KB
- 参考文档references/configuration.md4.7 KB
- 参考文档references/extension-workflow.md6.9 KB
- 参考文档references/repo-provenance.md2.2 KB
- 参考文档references/repo-routing-metadata.json445 B
- 参考文档references/troubleshooting.md6.4 KB
- 脚本scripts/check_template_static.py8.2 KB
- 脚本scripts/run_tiny_training_smoke.py5.3 KB
03 SKILL.md 正文
TensorFlow Project Template
Use this skill when the task is to understand, copy, modernize, debug, or extend the Tensorflow-Project-Template style of TensorFlow project: a model class, trainer class, data generator, JSON config, TensorBoard logger, checkpoint saver, and one main entry point wired together.
This repository is a small template, not an installable Python distribution. Treat it as project skeleton guidance: place the project root on PYTHONPATH or run from a checkout/copy of the template when validating code.
First choose the route
| User intent | Use this skill content |
|---|---|
| "How do I add my own model/trainer?" | Read extension workflow, then check API contracts in API reference. |
| "What config keys and paths does it expect?" | Read configuration. |
| "Why does import/training/logging/checkpointing fail?" | Read troubleshooting, then run scripts/check_template_static.py. |
| "Can this copied template still run?" | Run scripts/check_template_static.py; if TensorFlow 1.x is installed, run scripts/run_tiny_training_smoke.py. |
| "Is this skill current for my checkout?" | Read repository provenance. |
Runtime assumptions to check first
- The source uses TensorFlow 1.x graph APIs:
tf.Session,tf.placeholder,tf.variable_scope,tf.assign,tf.layers.dense,tf.train.Saver, andtf.summary.FileWriter. - A verified legacy runtime used Python 3.7,
tensorflow==1.15.5,numpy<1.19,tqdm,bunch, andprotobuf<3.20. - TensorFlow 2.x does not expose the required top-level symbols by default. If the user wants TensorFlow 2.x, plan a port to
tf.compat.v1or a full Keras rewrite; do not assume the original files run unchanged. - No GPU workflow is documented by this repo. CPU is sufficient for the template's example training smoke.
- The inspected source contains TensorBoard logging only. The README mentions Comet.ml, but the checked
Loggerimplementation has no Comet import or API call.
Minimal checks for a copied template project
From this generated skill directory, validate a target checkout or copied project:
python scripts/check_template_static.py --repo-root /path/to/template-copy
If the environment has TensorFlow 1.x-compatible APIs, run a bounded one-step smoke:
python scripts/run_tiny_training_smoke.py --repo-root /path/to/template-copy --work-dir /path/to/safe-smoke-workdir
Both scripts are self-contained skill helpers. They accept an explicit target project path; they do not depend on the original source checkout used to create this skill.
Template architecture
base/BaseModelowns shared checkpoint, current-epoch, and global-step behavior. A child model must implementbuild_model()andinit_saver().models/ExampleModelshows a TF1 graph with placeholders, dense layers, cross-entropy loss, Adam optimizer, accuracy, and a saver.base/BaseTrainowns session initialization and epoch looping. A child trainer must implementtrain_epoch()andtrain_step().trainers/ExampleTrainerfetches batches fromDataGenerator, runs the model train op, summarizes averaged loss/accuracy, and saves a checkpoint each epoch.data_loader/DataGeneratoris deliberately minimal; replace it with project-specific dataset loading while preserving thenext_batch(batch_size)contract or update the trainer accordingly.utils/config.process_config()reads a JSON config and derivessummary_dirandcheckpoint_dirunder../experiments/<exp_name>/relative to the current process.mains/example.pywires config parsing, directory creation, session, data, model, logger, trainer, checkpoint load, andtrainer.train().
When adapting the template
- Start by copying the skeleton model/trainer pattern, not by editing the base classes unless the shared loop/checkpoint contract must change.
- Keep config keys explicit and add new keys to the JSON before using them in model, data, logger, or trainer code.
- Keep tensor shapes aligned: the example model expects
xshaped[batch, 784]and labels shaped[batch, 10]. - For real datasets, make data iteration deterministic enough for small smoke tests before scaling training.
- If adding modern TensorFlow/Keras code, document whether the project remains TF1 graph-mode or becomes TF2 eager/Keras; mixing both silently is a common failure source.
Bundled references and helpers
- API reference records verified classes, methods, and important behavior.
- Extension workflow gives the end-to-end process for creating a new model/trainer/data pipeline.
- Configuration lists config keys, derived paths, CLI argument handling, and path gotchas.
- Troubleshooting maps predictable symptoms to concrete recovery steps.
- Repository provenance records the source snapshot and evidence paths.
- Router metadata is structured metadata for managed repo-skill import; do not edit it as prose.
scripts/check_template_static.pyvalidates template files, class hooks, config keys, and TF1 symbol usage without importing TensorFlow.scripts/run_tiny_training_smoke.pyruns an optional one-step training smoke against a target template copy when a TF1-compatible runtime is available.
Non-goals and cautions
- This skill does not teach generic TensorFlow, Keras, distributed training, dataset APIs, or Comet.ml integration beyond what the repository actually implements.
- Do not tell users that this repo is pip-installable unless their project copy adds packaging metadata.
- Do not run long training, download datasets, or write checkpoints outside an explicit temporary or user-approved work directory.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).