Repository navigation
Examples and Tutorials
Learn · Build · Train · Evaluate · Deploy
A practical guide to numerical computation, tensor operations, automatic differentiation, neural network development, optimization, model evaluation, and reproducible experimentation.
Home · Installation · Quick Start · API Reference
Maintained By & Owner: EveryO Contributors & @krishanth7
Important
Tutorial Compatibility
These tutorials target the EveryO v0.2.0 source API reviewed from the repository's default branch.
The examples use documented public exports and standard Python libraries. Exact runtime behavior should be verified with the installed version, and numerical outputs may vary slightly with floating-point precision.
- Overview
- Development Environment
- Tutorial 1 — First Tensor
- Tutorial 2 — Tensor Mathematics
- Tutorial 3 — Shapes and Matrix Multiplication
- Tutorial 4 — Automatic Differentiation
- Tutorial 5 — First Neural Network
- Tutorial 6 — Loss Functions
- Tutorial 7 — Training a Regression Model
- Tutorial 8 — Adam Optimizer
- Tutorial 9 — Model Evaluation
- Tutorial 10 — Inference
- Reproducibility
- Performance and Diagnostics
- Common Errors
- Testing Your Examples
- Additional Learning Resources
- Next Steps
This page introduces EveryO through progressively more advanced practical examples.
The tutorials begin with tensor creation and progress toward building and training a neural network.
After completing the tutorials, developers should understand how to:
- Create and inspect tensors.
- Perform numerical operations.
- Work with tensor dimensions.
- Calculate gradients.
- Construct neural networks.
- Select loss functions.
- Configure optimizers.
- Train a simple model.
- Evaluate predictions.
- Use inference contexts.
Installation
|
v
Tensor Fundamentals
|
v
Mathematical Operations
|
v
Automatic Differentiation
|
v
Neural Network Construction
|
v
Loss Functions
|
v
Model Training
|
v
Evaluation and Inference
- Python 3.9 or newer.
- Git.
- Python package installer.
- Supported operating system.
- EveryO source or installed package.
git clone https://github.com/krishanth7/EveryO.git
cd EveryOpython -m venv .venvActivate the environment.
Windows PowerShell:
.venv\Scripts\Activate.ps1Linux / macOS:
source .venv/bin/activatepython -m pip install -e .For development:
python -m pip install -e ".[dev]"import everyo as eo
print("EveryO version:", eo.__version__)Difficulty: Beginner
Objective: Create a tensor and inspect its data.
import everyo as eo
x = eo.tensor([1.0, 2.0, 3.0])
print("Tensor:", x)
print("Shape:", x.shape)
print("Data:", x.data)(3,)
The tensor function creates a tensor from supported input data.
The tensor's shape describes its dimensions.
The data property exposes the underlying NumPy array.
| Concept | Meaning |
|---|---|
| Tensor | Numerical data structure |
| Shape | Dimensions |
| Data | Stored numerical values |
| Dtype | Numerical representation |
Related: Tensor Engine
Difficulty: Beginner
Objective: Perform basic mathematical operations.
import everyo as eo
a = eo.tensor([1.0, 2.0, 3.0])
b = eo.tensor([4.0, 5.0, 6.0])
result = eo.add(a, b)
print(result.data)Expected numerical result:
[5. 7. 9.]
result = eo.multiply(a, b)
print(result.data)Expected numerical result:
[ 4. 10. 18.]
EveryO also provides arithmetic operators through its tensor class.
result = a + b
print(result.data)For element-wise addition:
[ c_i=a_i+b_i ]
For element-wise multiplication:
[ c_i=a_ib_i ]
These operations are used in:
- Feature transformations.
- Neural network computations.
- Loss calculations.
- Gradient computation.
- Numerical experimentation.
Difficulty: Beginner to Intermediate
Objective: Understand matrix dimensions and multiplication.
import everyo as eo
a = eo.tensor([
[1.0, 2.0],
[3.0, 4.0]
])
b = eo.tensor([
[5.0, 6.0],
[7.0, 8.0]
])
result = eo.matmul(a, b)
print(result.data)
print("Output shape:", result.shape)Expected numerical result:
[[19. 22.]
[43. 50.]]
Output shape:
(2, 2)
For matrices (A) and (B):
[ C=AB ]
Each result element is:
[ C_{ij}=\sum_k A_{ik}B_{kj} ]
If:
[ A\in\mathbb{R}^{m\times n} ]
and:
[ B\in\mathbb{R}^{n\times p} ]
then:
[ C\in\mathbb{R}^{m\times p} ]
Matrix multiplication requires compatible inner dimensions.
For example:
(2, 3) @ (4, 2)
is not valid standard matrix multiplication.
Difficulty: Intermediate
Objective: Compute a gradient using EveryO's autograd system.
Consider:
[ f(x)=x^2 ]
Its derivative is:
[ f'(x)=2x ]
At:
[ x=3 ]
the derivative is:
[ f'(3)=6 ]
import everyo as eo
x = eo.tensor(
3.0,
requires_grad=True
)
y = eo.multiply(x, x)
y.backward()
print("Gradient:", x.grad)The expected gradient is approximately 6.0.
- The input tensor enables gradient tracking.
- The multiplication creates a differentiable result.
- Calling
backward()computes gradients. - The gradient is stored on the input tensor.
x = 3
|
+------+
| |
v v
x * x
|
v
y = 9
|
v
backward()
|
v
dy/dx = 6
- Gradient tracking is required for relevant inputs.
- Operations must support differentiation.
- Repeated backward calls may accumulate gradients.
- Gradient shape must match the differentiated input.
Related: Automatic Differentiation
Difficulty: Intermediate
Objective: Build a feedforward neural network.
Input: 4 Features
|
v
Linear(4, 16)
|
v
ReLU
|
v
Linear(16, 2)
|
v
Output: 2 Features
import everyo as eo
model = eo.Sequential(
eo.Linear(4, 16, seed=0),
eo.ReLU(),
eo.Linear(16, 2, seed=1)
)
x = eo.zeros(3, 4)
output = model(x)
print("Output shape:", output.shape)Expected output:
Output shape: (3, 2)
The model contains:
- An input transformation.
- A nonlinear activation.
- An output transformation.
The batch contains three samples, each with four input features.
For the first layer:
[ P_1=4(16)+16=80 ]
For the second layer:
[ P_2=16(2)+2=34 ]
Total:
[ P=80+34=114 ]
This assumes biases are enabled in both linear layers.
The Sequential container executes its child modules in order.
Each layer receives the output of the previous layer.
Related: Neural Networks
Difficulty: Intermediate
Objective: Measure prediction error.
For regression:
[ L_{MSE}= \frac{1}{N} \sum_{i=1}^{N} (y_i-\hat y_i)^2 ]
import everyo as eo
predictions = eo.tensor([2.0, 4.0])
targets = eo.tensor([1.0, 3.0])
criterion = eo.MSELoss()
loss = criterion(predictions, targets)
print("Loss:", loss.item())Expected output:
Loss: 1.0
EveryO also exports:
| Loss | Typical Task |
|---|---|
MSELoss |
Regression |
MAELoss |
Regression |
BCELoss |
Binary classification |
BCEWithLogitsLoss |
Binary classification using logits |
CrossEntropyLoss |
Multiclass classification |
The inspected loss implementation supports:
meansumnone
Example:
criterion = eo.MSELoss(reduction="mean")Difficulty: Intermediate
Objective: Train a neural network to approximate a linear relationship.
We want the model to learn:
[ y=2x+1 ]
Training examples:
| Input | Target |
|---|---|
| 0 | 1 |
| 1 | 3 |
| 2 | 5 |
| 3 | 7 |
| 4 | 9 |
import everyo as eo
# 1. Prepare training data.
x = eo.tensor([
[0.0],
[1.0],
[2.0],
[3.0],
[4.0],
])
y = eo.tensor([
[1.0],
[3.0],
[5.0],
[7.0],
[9.0],
])
# 2. Create the model.
model = eo.Sequential(
eo.Linear(1, 1, seed=42)
)
# 3. Configure loss and optimizer.
criterion = eo.MSELoss()
optimizer = eo.SGD(
model.parameters(),
lr=0.01
)
# 4. Train the model.
for epoch in range(1000):
optimizer.zero_grad()
predictions = model(x)
loss = criterion(predictions, y)
loss.backward()
optimizer.step()
if (epoch + 1) % 100 == 0:
print(
f"Epoch {epoch + 1}: "
f"Loss = {loss.item():.6f}"
)
# 5. Evaluate.
with eo.no_grad():
test = eo.tensor([[5.0]])
prediction = model(test)
print("Prediction:", prediction.data)As training progresses, the loss should generally decrease for this simple dataset and configuration.
The prediction for input 5.0 should move toward:
[ y=2(5)+1=11 ]
The exact prediction depends on the learned parameters and training behavior.
Training Data
|
v
Linear Model
|
v
Predictions
|
v
MSE Loss
|
v
Backward Propagation
|
v
SGD Parameter Update
|
v
Repeat
- The learning rate controls update size.
- The loss measures prediction error.
- Backward propagation computes gradients.
- The optimizer updates parameters.
- Evaluation should use a separate dataset for realistic applications.
Related: Optimization
Difficulty: Intermediate
Objective: Configure adaptive gradient optimization.
import everyo as eo
model = eo.Sequential(
eo.Linear(4, 8, seed=0),
eo.ReLU(),
eo.Linear(8, 1, seed=1)
)
optimizer = eo.Adam(
model.parameters(),
lr=0.001
)
print("Optimizer configured")Adam(
parameters,
lr=0.001,
*,
betas=(0.9, 0.999),
eps=1e-8,
weight_decay=0.0,
amsgrad=False
)| Parameter | Purpose |
|---|---|
parameters |
Trainable tensors |
lr |
Learning rate |
betas |
Moment decay coefficients |
eps |
Numerical stability term |
weight_decay |
L2 penalty |
amsgrad |
AMSGrad variant |
| Feature | SGD | Adam |
|---|---|---|
| Update | Gradient-based | Adaptive moment-based |
| State | Optional momentum | First and second moments |
| Default LR | 0.01 |
0.001 |
| Use | General optimization | Adaptive optimization |
These default learning rates are taken from the inspected optimizer implementations.
Difficulty: Intermediate
Objective: Compare predictions with target values.
Useful regression metrics include:
- Mean squared error.
- Mean absolute error.
- Root mean squared error.
- Coefficient of determination.
import everyo as eo
predictions = eo.tensor([
[2.0],
[4.0],
[6.0]
])
targets = eo.tensor([
[2.5],
[3.5],
[5.5]
])
criterion = eo.MSELoss()
loss = criterion(predictions, targets)
print("MSE:", loss.item())Expected result:
MSE: 0.25
- Separate training and evaluation data.
- Avoid data leakage.
- Use metrics appropriate to the task.
- Compare against a baseline.
- Report dataset limitations.
- Track both training and validation performance.
Difficulty: Intermediate
Objective: Generate predictions without recording unnecessary gradient computations.
import everyo as eo
model = eo.Sequential(
eo.Linear(3, 8, seed=0),
eo.ReLU(),
eo.Linear(8, 2, seed=1)
)
model.eval()
input_data = eo.tensor([
[0.5, 1.0, 1.5]
])
with eo.no_grad():
prediction = model(input_data)
print("Prediction shape:", prediction.shape)
print("Prediction:", prediction.data)(1, 2)
Evaluation workflows may require:
- Disabling training-specific layer behavior.
- Avoiding unnecessary gradient tracking.
- Reducing computational overhead.
- Consistent preprocessing.
The eval() method controls module evaluation behavior, while no_grad() controls gradient recording.
Reproducibility helps developers investigate and compare experimental results.
- Random initialization.
- Dataset ordering.
- Dependency versions.
- Hardware.
- Numerical precision.
- Training hyperparameters.
- Backend behavior.
EveryO's inspected Linear constructor accepts a seed.
import everyo as eo
layer_a = eo.Linear(4, 2, seed=42)
layer_b = eo.Linear(4, 2, seed=42)This provides a reproducible initialization mechanism for the layer under the same implementation and environment.
Recommended fields:
| Field | Example |
|---|---|
| Framework Version | 0.2.0 |
| Python Version | Installed version |
| Model Architecture | Linear network |
| Optimizer | SGD |
| Learning Rate | 0.01 |
| Epochs | 1000 |
| Seed | 42 |
| Dataset | Experiment-specific |
everyo infoeveryo doctorpython -m pytest- Batch size.
- Tensor dimensions.
- Numerical precision.
- Backend selection.
- Memory allocation.
- Python overhead.
- Model complexity.
When reporting performance, include:
- Hardware.
- Operating system.
- Python version.
- EveryO version.
- Model architecture.
- Input shape.
- Number of repetitions.
- Timing methodology.
ModuleNotFoundError: everyo
Confirm the active Python environment and install the package:
python -m pip install -e .Tensor shape mismatch
Check the input and output dimensions of the operation.
For linear layers, the last input dimension must match in_features.
Gradients are missing
Check whether gradient tracking is enabled and whether the computation uses differentiable operations.
Loss does not decrease
Investigate:
- Learning rate.
- Model parameters.
- Data preprocessing.
- Gradient calculation.
- Training loop order.
Training produces NaN values
Check numerical stability, invalid operations, learning rate, and gradient magnitudes.
Optional backend unavailable
Verify installed dependencies, supported hardware, and EveryO backend compatibility.
EveryO includes a test suite that developers can use to validate supported functionality.
python -m pytestRecommended validation includes:
- Tensor creation.
- Mathematical operations.
- Gradient correctness.
- Layer output shapes.
- Loss calculations.
- Optimizer updates.
- Model evaluation.
- Serialization.
- Backend compatibility.
When an example fails:
- Record the error.
- Check the installed version.
- Reduce the example to a minimal reproduction.
- Compare the relevant API with the source.
- Create a focused regression test.
- Report unresolved issues.
| Resource | Description |
|---|---|
| Getting Started | Introduction and setup |
| Installation | Installation instructions |
| Quick Start | First framework examples |
| Tensor Engine | Numerical operations |
| Automatic Differentiation | Gradients and backpropagation |
| Neural Networks | Model architecture |
| Optimization | Optimizers |
| Backend System | Numerical execution |
| API Reference | Public Python API |
After completing these tutorials, developers can explore more advanced workflows.
| Next Page | Focus |
|---|---|
| Model Training | Training pipelines and callbacks |
| Data Pipeline | Datasets and preprocessing |
| Model Serialization | Saving and loading models |
| Performance Optimization | Profiling and benchmarking |
| Contributing | Development contributions |
Wiki links become active after the corresponding pages are created.
Next Recommended Page: Model Training →
Home · Quick Start · API Reference · Neural Networks
EveryO — Open Machine Learning. Built for Developers.
Maintained By & Owner:
EveryO Contributors & @krishanth7
Open Source · MIT Licensed · Community Driven
© 2026 EveryO Contributors