Skip to main content
rule

tensorflow-deep-learning — Cursor rule for TensorFlow models

This rule guides Cursor through TensorFlow project structure, data checks, model training, evaluation, and export. Use it when you want these practices applied to your Python files and notebooks.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/tensorflow-deep-learning.mdc
Open on GitHub

What tensorflow-deep-learning does

The rule targets *.py, *.ipynb, pyproject.toml, requirements*.txt, and environment*.yml. It recommends keeping data loading, model code, training, and evaluation in separate parts of a project. For input processing, it points to tf.data; repeatable notebook work belongs in modules, while model settings can live in typed configs.

Before training, check tensor shapes and types, label ranges, and class balance. The rule calls for splitting data before augmentation or fitting normalization, then using validation data for tuning and a separate test set for final results. This separation helps prevent leakage. Choose metrics that fit the task, and save the checkpoint with the strongest validation score rather than the last epoch.

For serving, keep preprocessing aligned with training, export a clear input signature, and smoke-test the saved model on sample inputs. The rule also calls for tracking latency, memory, and prediction drift. Mixed precision should wait until numerical stability has been checked; GPU runs may remain nondeterministic.

What it helps with

  • separate data loading, training, and evaluation code
  • check labels and class balance before fitting a model
  • prevent validation leakage during preprocessing
  • select a checkpoint by validation performance
  • smoke-test an exported model on sample inputs

Example prompts for the agent

  • Review this TensorFlow pipeline for data leakage between training and validation.
  • Move repeatable training code out of the notebook and into project modules.
  • Prepare the exported model with an input signature and a sample inference test.

How to install tensorflow-deep-learning

Manually: put the files in place

.cursor/rules/tensorflow-deep-learning.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about tensorflow-deep-learning

How do I install tensorflow-deep-learning in Cursor?

Add the rule file at .cursor/rules/tensorflow-deep-learning.mdc.

What does tensorflow-deep-learning do?

It gives Cursor guidance for structuring TensorFlow projects, checking datasets, training and evaluating models, and preparing exports for inference.

How does the rule address data leakage?

It recommends splitting the dataset before augmentation or fitting normalization, and keeping the test set separate from validation used for tuning.

Source text

tensorflow-deep-learning.mdc · CC0-1.0
---
description: TensorFlow and deep learning rules for building, training, evaluating, and deploying neural network models
globs: ["**/*.py", "**/*.ipynb", "pyproject.toml", "requirements*.txt", "environment*.yml"]
alwaysApply: false
---

# TensorFlow and Deep Learning Rules

## Project Structure

- Separate data loading, model definition, training, evaluation, and serving code.
- Use `tf.data` pipelines for scalable input processing.
- Keep model hyperparameters in typed config files or dataclasses.
- Store checkpoints, logs, and exported models outside source directories.
- Keep notebooks exploratory; move repeatable training code into modules.

## Model Development

- Start with a small baseline model and a tiny overfit test before scaling.
- Use Keras layers and models unless lower-level TensorFlow APIs are required.
- Prefer explicit input shapes and named inputs/outputs.
- Use callbacks for checkpointing, early stopping, learning-rate scheduling, and TensorBoard logging.
- Use mixed precision only after validating numerical stability.
- Pin random seeds where reproducibility matters, while documenting nondeterministic GPU behavior.

## Training

- Validate data shapes, dtypes, label ranges, and class balance before training.
- Split data before augmentation or normalization fitting.
- Use validation data for tuning and a separate test set for final reporting.
- Track loss curves, metrics, learning rate, and resource use.
- Save the best checkpoint by validation metric, not by final epoch.

## Evaluation

- Report task-appropriate metrics such as AUROC, F1, calibration, perplexity, BLEU/ROUGE, or MAE/RMSE.
- Include confusion matrices or error slices for classification tasks.
- Evaluate on edge cases and distribution shifts when data allows.
- Compare against non-neural baselines when the dataset is small or tabular.

## Deployment

- Export models with clear input signatures.
- Keep preprocessing consistent between training and serving.
- Add smoke tests that load the exported model and run inference on sample inputs.
- Monitor latency, memory, prediction drift, and input schema changes.

## Common Mistakes

- Do not tune architecture before verifying labels and data quality.
- Do not leak validation data through preprocessing or augmentation.
- Do not rely on accuracy alone for imbalanced data.
- Do not deploy a notebook-only model.
- Do not ignore batch size, dtype, and device differences between training and inference.

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for AI and ML →

From the same set210

typescript-expo-jest-detox-cursorrules-prompt-file A Cursor rule that points the assistant at TypeScript, React Native, Expo and mobile UI work. Useful when your app runs on Expo and you test it with Jest and Detox. ★ 41,024repo stars typescript-code-convention-cursorrules-prompt-file A Cursor rule that pins down TypeScript code style for Next.js App Router, React, Expo, tRPC and Tailwind projects. Useful when the agent writes code inconsistently. ★ 41,024repo stars toss-style-design-system This Cursor rule guides the agent toward restrained product interfaces with clear hierarchy, grayscale structure, and limited accent color. Use it when editing UI components or styles. ★ 41,024repo stars tokrepo-agent-discovery-cursorrules-prompt-file This Cursor rule makes the agent search TokRepo for existing skills, prompts and MCP configs before writing new ones, and verify every candidate before install. ★ 41,024repo stars tauri-svelte-typescript-guide-cursorrules-prompt-f A Cursor rule that sets how the agent writes desktop apps with Tauri: Svelte on the frontend, TypeScript for types. ★ 41,024repo stars tanstack-start-cursorrules-prompt-file Guides Cursor when building with TanStack Start, covering server functions, file-based routes, SSR, and streamed data. ★ 41,024repo stars tanstack-router A Cursor rule that sets agent conventions for TanStack Router v1: file-based routes, typed params and loader-based data fetching. ★ 41,024repo stars tanstack-query This Cursor rule guides TanStack Query v5 usage in React and TypeScript. Use it when building queries, mutations, pagination, or Suspense flows. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor