Step 1: intro
Lesson 1: Environment Setup. Before we generate art or text, we need a stable Python playground.
Code / Terminal Command:
# Terminal Check
$ python --versionStep 2: venv create
We create a Virtual Environment to isolate our GenAI libraries from the rest of the system.
Code / Terminal Command:
# Create virtual environment
$ python -m venv genai_envStep 3: activate
Now we activate it. Notice the visuals: our context shifts into the isolated 'genai_env' box.
Code / Terminal Command:
# Activate environment (Linux/Mac)
$ source genai_env/bin/activateStep 4: install libs
The core stack: PyTorch for tensor math, and Transformers (Hugging Face) for the models.
Code / Terminal Command:
# Install dependencies
$ pip install torch transformers numpyStep 5: script start
Let's create `main.py`. First, we import the libraries to verify they are accessible.
Code / Terminal Command:
import torch
from transformers import pipeline
# Check for GPU availability
device = 'cuda' if torch.cuda.is_available() else 'cpu'
print(f"Using device: {device}")Step 6: pipeline code
We'll add a simple 'pipeline' test. This downloads a tiny model to prove everything works.
Code / Terminal Command:
import torch
from transformers import pipeline
# Check for GPU availability
device = 'cuda' if torch.cuda.is_available() else 'cpu'
print(f"Using device: {device}")
# Initialize a simple sentiment analysis pipeline
classifier = pipeline('sentiment-analysis')
result = classifier('Generative AI is amazing!')
print(result)Step 7: execution
Back to the terminal. Run the script. If we see the tensor output, we are ready for Deep Learning.
Code / Terminal Command:
# Run the verification script
$ python main.pyStep 8: outro
Environment secure. Next lesson: We dive into the Mathematical Core—Probability & Statistics.
Code / Terminal Command:
# NEXT LESSON:
# 1. Tensors & Matrix Mult
# 2. Probability Distributions
# 3. Softmax Functions