0Pricing
Deep Learning Academy · Lektion

Notebooks, Skripte und reproduzierbare Seeds

Setzen Sie Zufalls-Seeds, damit sich Ergebnisse wiederholen.

Notebooks, Skripte und reproduzierbare Seeds ist eine kostenlose Deep Learning Academy-Lektion auf CoddyKit. Dies ist Lektion 3 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Deep Learning Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Deep Learning Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Two Ways to Work

You will write code in notebooks for quick experiments and in plain scripts for repeatable runs. Each suits a different moment.

Notebooks for Exploring

A notebook runs code in cells, showing plots and results inline. It is perfect for poking at data and trying ideas fast. 📓

Scripts for Real Runs

A script runs top to bottom in one go. Use it for training jobs you want to launch, share, and reproduce exactly.

python train.py

Watch Out for Cell Order

Notebook cells keep state even when you run them out of order, which can hide bugs. A script always starts from a clean slate.

The Reproducibility Problem

Deep learning uses random numbers for weights and shuffling. Run twice and you get different results unless you control that randomness.

Seeds to the Rescue

A seed fixes the starting point of the random number generator, so the same code produces the same numbers every single run.

Seed PyTorch

Set PyTorch's generator with one call. manual_seed makes weight initialization and any torch randomness repeatable.

torch.manual_seed(42)

Don't Forget NumPy and Python

Your code often pulls randomness from NumPy and Python too, so seed all three to make a run fully reproducible.

import numpy as np, random
np.random.seed(42)
random.seed(42)

Seed the GPU Too

When you train on CUDA, also seed the GPU generators. cuda.manual_seed_all covers every GPU device in your machine.

torch.cuda.manual_seed_all(42)

Wrap It in a Function

Bundle every seed call into one set_seed helper. Call it at the top of each run so you never forget a source of randomness.

def set_seed(s):
    torch.manual_seed(s)
    np.random.seed(s)

Why It Matters

Reproducible runs let you compare experiments fairly. If accuracy improves, you know it was your change, not random luck.

Quick Check

Recall what makes a run repeatable.

Recap

You saw when to use notebooks versus scripts and how seeding torch, NumPy, and Python makes every run reproducible. 🌱

Häufig gestellte Fragen

Ist die Lektion „Notebooks, Skripte und reproduzierbare Seeds“ kostenlos?

Ja — der vollständige Text von „Notebooks, Skripte und reproduzierbare Seeds“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Deep Learning Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Deep Learning Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Notebooks, Skripte und reproduzierbare Seeds“?

Setzen Sie Zufalls-Seeds, damit sich Ergebnisse wiederholen. Du übst Deep Learning Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Deep Learning Academy zu starten?

Keine Vorkenntnisse erforderlich. Deep Learning Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 3 von 4.

Wie lange dauert die Lektion „Notebooks, Skripte und reproduzierbare Seeds“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Deep Learning Academy-Lektion Code schreiben und ausführen?

Ja. Jede Deep Learning Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. PyTorch installieren und den Import überprüfen
  2. CPU vs. GPU vs. MPS: Gerät auswählen
  3. Notebooks, Skripte und reproduzierbare Seeds
  4. Ihr erstes torch.tensor
← Zurück zu Deep Learning Academy