# Microsoft AI-For-Beginners: Complete Guide to Examples and Tutorials

> Explore the Microsoft AI-For-Beginners repository for comprehensive tutorials and quick-start examples. Master AI concepts with hands-on learning resources. Start your AI journey today!

- Repository: [Microsoft/AI-For-Beginners](https://github.com/microsoft/AI-For-Beginners)
- Tags: getting-started
- Published: 2026-08-24

---

**The AI-For-Beginners repository from Microsoft provides both structured curriculum tutorials under `lessons/` and quick-start example scripts under `examples/`.**

This open-source learning platform combines self-contained Jupyter notebooks with standalone Python scripts covering neural networks, computer vision, NLP, and more. Every tutorial includes PyTorch and TensorFlow implementations alongside hands-on lab exercises.

---

## Curriculum Tutorials: The `lessons/` Directory

The core learning path resides in `lessons/`, organized by AI sub-field with progressive difficulty.

### Lesson Structure

Each tutorial follows a consistent three-part format:

- **Theory** – conceptual explanations with diagrams
- **Executable notebooks** – dual implementations in PyTorch and TensorFlow
- **Lab notebooks** – optional hands-on practice problems

### Featured Tutorial: Perceptron Implementation

The Perceptron lesson at `lessons/3-NeuralNetworks/03-Perceptron/` demonstrates this structure. Open `Perceptron.ipynb` to see a complete walkthrough of Rosenblatt's perceptron algorithm with NumPy implementation and visualization of decision boundaries.

Other notable tutorials include:

- **Convolutional Neural Networks** – `lessons/4-ComputerVision/07-ConvNets/ConvNetsPyTorch.ipynb`
- **BERT-Style Transformers** – `lessons/5-NLP/18-Transformers/TransformersPyTorch.ipynb`

---

## Quick-Start Examples: The `examples/` Directory

For learners wanting immediate runnable code, `examples/` contains four starter scripts documented in [`examples/README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/examples/README.md).

### 1. Hello AI World ([`examples/01-hello-ai-world.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/examples/01-hello-ai-world.py))

A minimal pattern-recognition script using rule-based classification on synthetic 2D data:

```python

# Minimal pattern-recognition example

import numpy as np

# Generate synthetic data: two classes in 2-D

np.random.seed(0)
X = np.vstack([np.random.randn(50, 2) + np.array([2, 2]),
               np.random.randn(50, 2) + np.array([-2, -2])])
y = np.hstack([np.ones(50), np.zeros(50)])

# Simple rule-based classifier

def predict(X):
    return (X[:, 0] + X[:, 1] > 0).astype(int)

pred = predict(X)
accuracy = (pred == y).mean()
print(f"Accuracy: {accuracy:.2f}")

```

### 2. Simple Neural Network ([`examples/02-simple-neural-network.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/examples/02-simple-neural-network.py))

Builds a two-layer network from scratch to solve the XOR problem using PyTorch:

```python
import torch
import torch.nn as nn
import torch.optim as optim

# Dummy data: XOR problem

X = torch.tensor([[0.,0.],[0.,1.],[1.,0.],[1.,1.]])
y = torch.tensor([[0.],[1.],[1.],[0.]])

# Two-layer network

model = nn.Sequential(
    nn.Linear(2, 2),
    nn.Sigmoid(),
    nn.Linear(2, 1),
    nn.Sigmoid()
)

criterion = nn.BCELoss()
optimizer = optim.SGD(model.parameters(), lr=0.1)

for epoch in range(5000):
    optimizer.zero_grad()
    output = model(X)
    loss = criterion(output, y)
    loss.backward()
    optimizer.step()

print("Trained model output:", model(X).detach().numpy())

```

### 3. Image Classifier (`examples/03-image-classifier.ipynb`)

An end-to-end notebook training a CNN on MNIST digits. The workflow includes data loading, Keras model definition, training with callbacks, and accuracy evaluation. Access directly via GitHub blob view for interactive exploration.

### 4. Text Sentiment ([`examples/04-text-sentiment.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/examples/04-text-sentiment.py))

Demonstrates binary sentiment analysis using scikit-learn's Naive Bayes classifier:

```python
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB

docs = ["I love this product", "This is terrible", "Excellent quality", "Not worth the money"]
labels = [1, 0, 1, 0]                     # 1 = positive, 0 = negative

vec = CountVectorizer()
X = vec.fit_transform(docs)

clf = MultinomialNB()
clf.fit(X, labels)

test = ["I hate it", "Great value"]
print(clf.predict(vec.transform(test)))   # → [0 1]

```

---

## Interactive Learning Tools

Beyond notebooks and scripts, the repository includes `etc/quiz-app/`, a Vue.js application for testing comprehension of tutorial material. Run this locally to validate understanding after completing lessons.

---

## Key File Reference

| Path | Purpose |
|------|---------|
| [`README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/README.md) | Curriculum overview and quick-start guide |
| [`examples/README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/examples/README.md) | Documentation for starter scripts |
| [`examples/01-hello-ai-world.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/examples/01-hello-ai-world.py) | Minimal classification example |
| [`examples/02-simple-neural-network.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/examples/02-simple-neural-network.py) | XOR solver with PyTorch |
| `examples/03-image-classifier.ipynb` | MNIST CNN training |
| [`examples/04-text-sentiment.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/examples/04-text-sentiment.py) | Naive Bayes sentiment analysis |
| `lessons/3-NeuralNetworks/03-Perceptron/Perceptron.ipynb` | Perceptron algorithm tutorial |
| `lessons/4-ComputerVision/07-ConvNets/ConvNetsPyTorch.ipynb` | CNN computer vision tutorial |
| `lessons/5-NLP/18-Transformers/TransformersPyTorch.ipynb` | BERT transformer tutorial |
| [`etc/quiz-app/README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/etc/quiz-app/README.md) | Quiz application setup instructions |

---

## Summary

- **Two learning modes**: Structured curriculum (`lessons/`) for comprehensive study, quick examples (`examples/`) for immediate experimentation
- **Dual framework support**: Every tutorial provides both PyTorch and TensorFlow implementations
- **Progressive difficulty**: From Hello World scripts to transformer architectures
- **Version-controlled access**: All files linked to GitHub blob view for direct source inspection
- **Validation tools**: Quiz application for self-assessment

---

## Frequently Asked Questions

### Does AI-For-Beginners require prior programming experience?

Basic Python knowledge is assumed. The examples start with simple NumPy operations and gradually introduce PyTorch/TensorFlow concepts. Beginners should complete the [`01-hello-ai-world.py`](https://github.com/microsoft/AI-For-Beginners/blob/main/01-hello-ai-world.py) script before attempting neural network tutorials.

### Can I run the notebooks without installing anything?

Yes. The repository supports GitHub Codespaces and Binder integration. Click any `.ipynb` file in the GitHub interface to open a cloud-based Jupyter environment with dependencies pre-installed.

### Are the examples production-ready?

No. The `examples/` scripts prioritize educational clarity over engineering robustness. For production patterns, Microsoft recommends the separate **AI-For-Experienced-Developers** curriculum after completing this beginner track.

### How do I contribute new tutorials to the repository?

Fork the repository and follow the lesson template in `lessons/_template/`. Each contribution must include theory markdown, working notebooks in both PyTorch and TensorFlow, and corresponding unit tests. Submit via pull request to the `main` branch.