Przejdź do treści
Biblioteka skilli
Dane i analityka · Budowanie i kod

tensorflow

/tensorflow

Doradza w TensorFlow 2.x: potoki tf.data, serializacja SavedModel, TensorBoard i strategie dystrybucji na wiele GPU, przy budowie i wdrażaniu produkcyjnych modeli ML.

Repozytorium
Agent-Skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
01.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 01.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Doradza w TensorFlow 2.x: potoki tf.data, serializacja SavedModel, TensorBoard i strategie dystrybucji na wiele GPU, przy budowie i wdrażaniu produkcyjnych modeli ML.

Oryginalny opis (EN)

Expert TensorFlow 2.x assistance covering tf.data pipelines, SavedModel serialization, TensorBoard, and multi-GPU distribution strategies. Use when building, training, and deploying production machine learning models.

Jak działa

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Sekcje z nagłówków SKILL.md, w oryginale · 143 linii, 539 słów
Podgląd SKILL.md
---
name: tensorflow
description: Expert TensorFlow 2.x assistance covering tf.data pipelines, SavedModel serialization, TensorBoard, and multi-GPU distribution strategies. Use when building, training, and deploying production machine learning models.
---

# TensorFlow

TensorFlow is an end-to-end open-source machine learning platform with extensive production deployment tooling, Keras integrations, and mobile/embedded optimization via TensorFlow Lite.

## When to Use

- **Enterprise Production Machine Learning**: End-to-end model deployment with TensorFlow Serving and TFX.
- **Mobile & Embedded Edge Inference**: Compiling models to microcontrollers and mobile apps using TensorFlow Lite (TFLite).
- **High-Performance Data Pipelines with tf.data**: Prefetching, interleaving, and streaming terabyte-scale datasets.
- **Distributed Training Across GPU/TPU Pods**: Scaling multi-worker distributed training with `tf.distribute.MirroredStrategy`.

## Quick Start

```python
import tensorflow as tf

# Define sequential classification model
model = tf.keras.Sequential([
    tf.keras.layers.Dense(128, activation='relu', input_shape=(30,)),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(2, activation='softmax')
])

model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
```

## Core Concepts

### High-Throughput Input Pipelines with tf.data

Asynchronous data loading with prefetching and parallel mapping:

```python
import tensorflow as tf

def parse_image_sample(filename, label):
    image_raw = tf.io.read_file(filename)
    image = tf.io.decode_jpeg(image_raw, channels=3)
    image = tf.image.resize(image, [224, 224])
    image = tf.cast(image, tf.float32) / 255.0 # Normalize
    return image, label

def create_dataset(filenames, labels, batch_size=64):
    dataset = tf.data.Dataset.from_tensor_slices((filenames, labels))
    dataset = dataset.shuffle(buffer_size=1000)
    # Interleave and map in parallel across all CPU cores
    dataset = dataset.map(parse_image_sample, num_parallel_calls=tf.data.AUTOTUNE)
    dataset = dataset.batch(batch_size)
    # Prefetch batches to GPU memory while current batch trains
    dataset = dataset.prefetch(buffer_size=tf.data.AUTOTUNE)
    return dataset
```

### Functional Model & Multi-GPU Distribution

Training models across multiple GPUs with `MirroredStrategy`:

```python
strategy = tf.distribute.MirroredStrategy()
print(f"Number of distributed devices: {strategy.num_replicas_in_sync}")

with strategy.scope():
    inputs = tf.keras.Input(shape=(224, 224, 3))
    x = tf.keras.layers.Conv2D(32, 3, activation='relu', padding='same')(inputs)
    x = tf.keras.layers.MaxPooling2D()(x)
    x = tf.keras.layers.Conv2D(64, 3, activation='relu', padding='same')(x)
    x = tf.keras.layers.GlobalAveragePooling2D()(x)
    outputs = tf.keras.layers.Dense(10, activation='softmax')(x)

    model = tf.keras.Model(inputs=inputs, outputs=outputs)
    model.compile(
        optimizer=tf.keras.optimizers.Adam(learning_rate=1e-3),
        loss='sparse_categorical_crossentropy',
        metrics=['accuracy']
    )

# model.fit(train_dataset, epochs=10)
```

### Exporting to TensorFlow Lite (TFLite) with INT8 Quantization

Compressing models for mobile deployment:

```python
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]

# Convert model to quantized TFLite binary
tflite_model = converter.convert()

with open("model_quantized.tflite", "wb") as f:
    f.write(tflite_model)
print("Saved optimized TFLite model.")
```

## Common Patterns

### High-Throughput Input Pipelines with tf.data Prefetching

**Problem**: GPU stays idle waiting for CPU to read, decode, and batch training data.

**Solution**:
Use `tf.data.AUTOTUNE` prefetching:

```python
dataset = tf.data.Dataset.from_tensor_slices((X_train, y_train))
dataset = (
    dataset.shuffle(buffer_size=10000)
    .batch(64)
    .prefetch(buffer_size=tf.data.AUTOTUNE) # Overlaps preprocessing with GPU compute
)

model.fit(dataset, epochs=10)
```

## Best Practices

**Do**:

- Always use `num_parallel_calls=tf.data.AUTOTUNE` and `.prefetch(tf.data.AUTOTUNE)` in input pipelines.
- Use `tf.distribute.MirroredStrategy` for seamless single-node multi-GPU data parallelism.
- Wrap heavy computation inside `@tf.function` to compile graphs via AutoGraph for C++ execution speeds.
- Save models in the modern `SavedModel` or `.keras` format rather than legacy checkpoint files.

**Don't**:

- Use Python operations inside `@tf.function`; use `tf.*` operations to ensure clean graph tracing.
- Execute feed-dict or session APIs; legacy TensorFlow 1.x patterns are completely deprecated.
- Train on CPU when GPU/TPU acceleration is available; verify devices with `tf.config.list_physical_devices('GPU')`.

## Troubleshooting

| Error                                                | Cause                                                       | Solution                                                                                             |
| :--------------------------------------------------- | :---------------------------------------------------------- | :--------------------------------------------------------------------------------------------------- |
| `ResourceExhaustedError: OOM when allocating tensor` | Batch size or model weights exceed GPU VRAM.                | Reduce batch size or configure memory growth: `tf.config.experimental.set_memory_growth(gpu, True)`. |
| `TensorFlow not detecting GPU`                       | Missing CUDA/cuDNN driver libraries in system library path. | Check detected devices via `tf.config.list_physical_devices('GPU')`.                                 |
| `Graph execution error: Incompatible shapes`         | Input tensor shape mismatch in first model layer.           | Verify input batch dimension matches `input_shape`.                                                  |

## References

- [TensorFlow Documentation](https://www.tensorflow.org/)

Wersje

RepozytoriumWynikLicencja
Ta strona · G1Joshi/Agent-Skills100MIT
TerminalSkills/skills100Apache-2.0
dkbnull/hello-skill100MIT

Migawka bazy z 13.11.2026 · wersja paczki 721cd30a42ac (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100tensorflow-savedmodel-creator
    Prawdopodobnie tworzy modele SavedModel w TensorFlow w kategorii ML Deployment, uruchamiane frazami typu „tensorflow savedmodel creator”.
  • 100tensorflow-model-trainer
    Prawdopodobnie obsługuje trenowanie modeli w TensorFlow w kategorii ML Training, uruchamiane frazami typu „tensorflow model trainer”.
  • 100tensorflow-deep-learning
    Podpowiada praktyki budowy, trenowania, oceny i wdrażania sieci w TensorFlow i Keras: potoki tf.data, callbacki checkpointów i early stopping oraz eksport modelu do serwowania.
  • 100keras
    Wspiera pracę z Keras 3: wykonanie na wielu backendach (JAX, PyTorch, TensorFlow), API Sequential i Functional oraz własne pętle treningowe modeli głębokiego uczenia.
  • 95ray-data
    Skalowalnie przetwarza dane dla ML ze strumieniowym wykonaniem na CPU i GPU, z obsługą Parquet, CSV, JSON i obrazów, do inferencji wsadowej, preprocessingu i rozproszonego ETL.
  • 100ml-engineer
    Buduje produkcyjne systemy ML w PyTorch 2.x i TensorFlow: serwowanie modeli, inżynierię cech, testy A/B i monitoring.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.