tensorflow-deep-learning
БесплатноБез исполняемых скриптовНе проверенBest practices for building, training, evaluating, and deploying neural networks with TensorFlow and Keras. Use when writing tf.data input pipelines, defining…
от Mindrally★ 323 звезды на GitHubОб этом скилле
TensorFlow and Deep Learning
This skill covers project structure, model development, training, evaluation, and deployment practices for neural networks built with TensorFlow and Keras.
Workflow for Training and Shipping a Model
- Separate concerns into modules — Keep data loading, model definition, training, evaluation, and serving code in distinct files; treat notebooks as exploratory only.
- Build the input pipeline first — Use
tf.data.Datasetfor scalable, prefetching input processing; validate shapes, dtypes, label ranges, and class balance before writing any model code. - Split before any fitting — Create train/validation/test splits before fitting normalization statistics or augmentation parameters, to avoid leakage.
- Start with a tiny baseline — Build a small model and run a tiny overfit test (fit on a handful of examples until loss goes to ~0) to prove the training loop works before scaling up.
- Train with callbacks — Wire in
ModelCheckpoint(save best by validation metric, not final epoch),EarlyStopping, a learning-rate schedule, andTensorBoardlogging. - Evaluate with task-appropriate metrics — Use a held-out test set only for final reporting, never for tuning.
- Export with a explicit signature — Save with
model.export()ortf.saved_model.save()and define serving input signatures explicitly. - Smoke test the export — Load the exported model and run inference on sample inputs before deploying.
Project Structure
- Separate data loading, model definition, training, evaluation, and serving code into distinct modules (e.g.,
data.py,model.py,train.py,evaluate.py,serve.py). - Keep model hyperparameters in typed config objects (dataclasses) or config files, not scattered as literals through training code.
- Store checkpoints, logs, and exported models outside source directories (e.g., under
artifacts/or a configured output path), so they don't get swept into version control accidentally. - Keep notebooks exploratory; once an approach is validated, move the repeatable training code into modules that can be run as scripts and covered by tests.
project/
data.py # tf.data pipeline construction
model.py # Keras model definition
config.py # typed hyperparameter config
train.py # training loop / Keras fit orchestration
evaluate.py # metrics computation on held-out data
serve.py # export + inference smoke test
artifacts/ # checkpoints, logs, saved models (gitignored)
Input Pipeline (tf.data)
import tensorflow as tf
def build_dataset(file_pattern: str, batch_size: int, shuffle: bool) -> tf.data.Dataset:
files = tf.data.Dataset.list_files(file_pattern, shuffle=shuffle)
ds = files.interleave(
tf.data.TFRecordDataset,
cycle_length=tf.data.AUTOTUNE,
num_parallel_calls=tf.data.AUTOTUNE,
)
ds = ds.map(_parse_example, num_parallel_calls=tf.data.AUTOTUNE)
if shuffle:
ds = ds.shuffle(buffer_size=10_000)
ds = ds.batch(batch_size, drop_remainder=False)
return ds.prefetch(tf.data.AUTOTUNE)
def _parse_example(record: tf.Tensor) -> tuple[tf.Tensor, tf.Tensor]:
feature_spec = {
"features": tf.io.FixedLenFeature([32], tf.float32),
"label": tf.io.FixedLenFeature([], tf.int64),
}
parsed = tf.io.parse_single_example(record, feature_spec)
return parsed["features"], parsed["label"]
- Use
num_parallel_calls=tf.data.AUTOTUNEon.map()/.interleave()and always end the pipeline with.prefetch(tf.data.AUTOTUNE). - Shuffle before batching, with a buffer large enough to approximate a full shuffle for the dataset size.
- Validate data shapes, dtypes, label ranges, and class balance on a sample batch before starting a long training run.
Model Development
- Use Keras layers and models (
tf.keras.Model,tf.keras.Sequential) unless a specific need requires lower-leveltf.GradientTapecontrol. - Prefer explicit input shapes and named inputs/outputs — this makes serving signatures and debugging easier.
- Start with a small baseline model and confirm it can overfit a tiny subset of data (loss near zero) before scaling depth, width, or dataset size — this catches pipeline and loss-function bugs early.
- Pin random seeds (
tf.random.set_seed,numpy.random.seed) where reproducibility matters, but document that GPU execution can still be nondeterministic for some ops (e.g., certain cuDNN reductions). - Only enable mixed precision (
tf.keras.mixed_precision.set_global_policy("mixed_float16")) after validating numerical stability at full precision — some losses (e.g., ones involvinglogorexp) need loss scaling to avoid underflow.
import tensorflow as tf
def build_model(input_dim: int, num_classes: int) -> tf.keras.Model:
inputs = tf.keras.Input(shape=(input_dim,), name="features")
x = tf.keras.layers.Dense(128, activation="relu")(inputs
Установить tensorflow-deep-learning в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл tensorflow-deep-learning?
Best practices for building, training, evaluating, and deploying neural networks with TensorFlow and Keras. Use when writing tf.data input pipelines, defining or training a Keras model, configuring callbacks for checkpointing and early stopping, evaluating a trained model, or exporting a model for serving.
Как установить скилл tensorflow-deep-learning?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл tensorflow-deep-learning запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic