Skip to content

Advanced‐Tutorials

Krishanth edited this page Oct 15, 2026 · 1 revision

Advanced Tutorials

EveryO — Advanced Neural Computing & Applied Machine Learning

Build · Experiment · Validate · Optimize

EveryO Tutorials Python License

A practical learning pathway for advanced model development, numerical verification, training workflows, acceleration, and interoperability.

Home · Getting Started · API Reference · Examples and Tutorials


Repository: krishanth7/EveryO

Maintainer: @krishanth7

Audience: Intermediate and advanced Python developers, ML engineers, and researchers

Document Status: Tutorial guidance

Important

Before You Begin

EveryO is an experimental, NumPy-based neural computing framework intended for learning, experimentation, and numerical verification.

Advanced features may require optional dependencies, specific hardware, or supported input shapes.

The examples below illustrate documented APIs and engineering patterns. Validate them against your installed EveryO version before using them in larger projects.


Table of Contents

  1. Introduction
  2. Prerequisites
  3. Development Environment
  4. Advanced Learning Path
  5. Tensor Computation
  6. Computational Graphs
  7. Gradient Verification
  8. Custom Neural Network Modules
  9. Multilayer Perceptrons
  10. Convolutional Networks
  11. Normalization and Regularization
  12. Recurrent Neural Networks
  13. LSTM and GRU Architectures
  14. Attention Mechanisms
  15. Transformer Encoders
  16. Advanced Training Pipelines
  17. Gradient Clipping
  18. Learning Rate Scheduling
  19. Early Stopping
  20. Checkpointing and Serialization
  21. Mixed Precision
  22. CUDA Acceleration
  23. Distributed Training
  24. ONNX Export
  25. Quantization
  26. Profiling and Optimization
  27. Reproducible Experiments
  28. Debugging Advanced Models
  29. Advanced Exercises
  30. Learning Roadmap
  31. Official Resources

1. Introduction

The Advanced Tutorials section helps developers move beyond introductory tensor operations and build more sophisticated machine learning experiments.

1.1 Learning Objectives

By completing this guide, readers should understand how to:

  • Compose neural network architectures.
  • Inspect computational graphs.
  • Verify analytical gradients.
  • Work with convolutional and sequence models.
  • Design reliable training workflows.
  • Validate model serialization.
  • Evaluate optional acceleration.
  • Export supported models to ONNX.
  • Profile computational bottlenecks.

1.2 Recommended Approach

        TENSOR FOUNDATIONS
                |
                v
        AUTOGRAD VALIDATION
                |
                v
        CUSTOM ARCHITECTURES
                |
                v
        ADVANCED TRAINING
                |
                v
       SEQUENCE AND ATTENTION
                |
                v
        MODEL SERIALIZATION
                |
                v
        OPTIONAL ACCELERATION
                |
                v
        INTEROPERABILITY
                |
                v
       REPRODUCIBLE RESULTS

2. Prerequisites

Before proceeding, readers should understand:

  • Python programming.
  • NumPy arrays.
  • Matrix multiplication.
  • Basic calculus.
  • Neural network fundamentals.
  • Gradient descent.
  • Training and validation datasets.

2.1 Recommended Previous Pages


3. Development Environment

3.1 Clone the Repository

git clone https://github.com/krishanth7/EveryO.git

cd EveryO

3.2 Create a Virtual Environment

python -m venv .venv

Linux/macOS:

source .venv/bin/activate

Windows PowerShell:

.\.venv\Scripts\Activate.ps1

3.3 Install the Framework

python -m pip install -e .

3.4 Install Development Tools

python -m pip install -e ".[dev]"

3.5 Verify Installation

everyo info

everyo doctor

4. Advanced Learning Path

Level Topic Expected Outcome
1 Tensor operations Understand shapes and numerical behavior
2 Automatic differentiation Verify computational gradients
3 Custom modules Build reusable architectures
4 CNNs Process spatial data
5 Recurrent networks Model sequences
6 Attention Understand contextual representations
7 Training pipelines Manage optimization experiments
8 CUDA Evaluate optional acceleration
9 ONNX Validate interoperability
10 Profiling Identify computational bottlenecks

5. Tensor Computation

5.1 Create Tensors

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],
])

c = eo.matmul(a, b)

print(c)
print(c.shape)

Expected numerical output:

[[19. 22.]
 [43. 50.]]

Expected shape:

(2, 2)

5.2 Mathematical Definition

[ C_{ij}=\sum_k A_{ik}B_{kj} ]

5.3 Exercise

Modify the input matrices to use:

  • A 3 × 4 matrix.
  • A 4 × 2 matrix.

Verify that the result has shape (3, 2).


6. Computational Graphs

Automatic differentiation tracks operations required to compute gradients.

6.1 Example

import everyo as eo

x = eo.tensor(
    [2.0],
    requires_grad=True,
)

a = x * x
b = a * x
y = b + x

y.backward()

print(x.grad)

6.2 Mathematical Derivation

[ y=x^3+x ]

Therefore:

[ \frac{dy}{dx}=3x^2+1 ]

At (x=2):

[ \frac{dy}{dx}=13 ]

Expected gradient:

[13.]

6.3 Graph Structure

             x
             |
         +---+---+
         |       |
         v       |
        x*x      |
         |       |
         v       |
        *x       |
         |       |
         +---+---+
             |
             v
            Add
             |
             v
              y
             |
             v
          Backward

7. Gradient Verification

Gradient checking is essential when developing custom mathematical operations.

7.1 Central Difference

[ g_{\text{numeric}}= \frac{f(x+h)-f(x-h)}{2h} ]

7.2 Example

def f(x):
    return x ** 3 + x


x = 2.0
h = 1e-5

numeric_gradient = (
    f(x + h) - f(x - h)
) / (2 * h)

analytic_gradient = 3 * x ** 2 + 1

print("Numeric:", numeric_gradient)
print("Analytic:", analytic_gradient)
print(
    "Absolute error:",
    abs(numeric_gradient - analytic_gradient),
)

7.3 Validation Criteria

Use a justified combination of absolute and relative tolerances.

7.4 Exercise

Implement gradient checks for:

  • Squaring.
  • Multiplication.
  • Matrix multiplication.
  • Mean reduction.

8. Custom Neural Network Modules

EveryO includes Module and Parameter abstractions.

8.1 Why Custom Modules Matter

Custom modules help organize:

  • Reusable layers.
  • Model components.
  • Trainable parameters.
  • Forward computations.

8.2 Design Principles

A custom module should:

  1. Define its parameters clearly.
  2. Implement a predictable forward computation.
  3. Preserve gradient tracking.
  4. Handle invalid shapes appropriately.
  5. Support the relevant model lifecycle.

8.3 Recommended Structure

        CUSTOM MODULE
              |
       +------+------+
       |             |
       v             v
   PARAMETERS      FORWARD
       |             |
       +------+------+
              |
              v
           OUTPUT
              |
              v
         AUTOGRAD GRAPH

8.4 Serialization

Custom modules intended for .evo serialization should follow the documented registration mechanism, including @register_module where applicable.

8.5 Exercise

Implement a custom residual block using documented module operations.

Verify its output shape and gradients before using it in a larger model.


9. Multilayer Perceptrons

9.1 Architecture

import everyo as eo

model = eo.Sequential(
    eo.Linear(8, 32),
    eo.ReLU(),
    eo.Linear(32, 16),
    eo.ReLU(),
    eo.Linear(16, 3),
)

9.2 Forward Execution

x = eo.tensor([
    [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0],
])

output = model(x)

print(output.shape)

Expected shape:

(1, 3)

9.3 Architecture Diagram

        INPUT (8)
            |
            v
       LINEAR (32)
            |
            v
           RELU
            |
            v
       LINEAR (16)
            |
            v
           RELU
            |
            v
        LINEAR (3)
            |
            v
          OUTPUT

9.4 Exercise

Compare models with different hidden layer widths while keeping the dataset and optimizer configuration constant.


10. Convolutional Networks

EveryO provides convolutional and pooling layers.

10.1 Image Layout

EveryO's documented convolution input format is NHWC:

(batch, height, width, channels)

10.2 Example Input

import numpy as np
import everyo as eo

images = eo.tensor(
    np.random.default_rng(42).random(
        (4, 28, 28, 1)
    )
)

print(images.shape)

Expected shape:

(4, 28, 28, 1)

10.3 Typical CNN Pipeline

          IMAGE
            |
            v
        CONVOLUTION
            |
            v
           RELU
            |
            v
         POOLING
            |
            v
         FLATTEN
            |
            v
        LINEAR
            |
            v
       CLASSIFICATION

10.4 Repository Example

python examples/convolutional_network.py

10.5 Exercise

Investigate how kernel size, stride, and padding affect output dimensions.


11. Normalization and Regularization

11.1 Available Components

EveryO includes:

  • BatchNorm1D.
  • BatchNorm2D.
  • LayerNorm.
  • Dropout.

11.2 Batch Normalization

[ \hat{x}= \frac{x-\mu}{\sqrt{\sigma^2+\epsilon}} ]

11.3 Dropout

Dropout randomly disables selected activations during training.

11.4 Training Versus Evaluation

Layers such as dropout and batch normalization may behave differently depending on model mode.

11.5 Exercise

Compare a baseline model with a model using regularization.

Report both training and validation metrics.


12. Recurrent Neural Networks

Recurrent neural networks process sequential information.

12.1 General Recurrence

[ h_t=f(W_xx_t+W_hh_{t-1}+b) ]

12.2 Sequence Representation

A sequence input typically includes:

  • Batch dimension.
  • Time dimension.
  • Feature dimension.

Verify the precise shape contract of the chosen EveryO recurrent layer.

12.3 Example Program

python examples/sequence_models.py

12.4 Recommended Validation

  • Verify input shapes.
  • Check hidden-state dimensions.
  • Test different sequence lengths.
  • Validate gradients through time.

13. LSTM and GRU Architectures

13.1 LSTM

Long Short-Term Memory networks use gates to regulate information flow.

Typical components include:

  • Input gate.
  • Forget gate.
  • Output gate.
  • Cell state.

13.2 GRU

Gated Recurrent Units use a smaller gating structure.

Typical components include:

  • Update gate.
  • Reset gate.
  • Hidden state.

13.3 Comparison

Architecture Characteristic
Basic RNN Simple recurrence
LSTM Separate cell and hidden states
GRU Gated recurrence with fewer gate types

13.4 Exercise

Compare RNN, LSTM, and GRU models on the same synthetic sequence prediction task.

Record convergence and computational cost.


14. Attention Mechanisms

Attention allows a model to compute context-dependent representations.

14.1 Scaled Dot-Product Attention

[ Attention(Q,K,V)= softmax\left( \frac{QK^T}{\sqrt{d_k}} \right)V ]

where:

  • (Q): Queries.
  • (K): Keys.
  • (V): Values.
  • (d_k): Key dimension.

14.2 Computational Flow

         QUERY      KEY
           |         |
           +----+----+
                |
                v
             Q × Kᵀ
                |
                v
          SCALE SCORES
                |
                v
             SOFTMAX
                |
                v
          WEIGHTED VALUES
                |
                v
              OUTPUT

14.3 Multi-Head Attention

Multiple attention heads learn different representation subspaces.

14.4 Validation

Verify:

  • Tensor shapes.
  • Attention score normalization.
  • Output dimensions.
  • Gradient propagation.

15. Transformer Encoders

EveryO includes Transformer encoder components.

15.1 Typical Encoder Structure

          INPUT
            |
            v
     POSITION ENCODING
            |
            v
    MULTI-HEAD ATTENTION
            |
            v
       RESIDUAL PATH
            |
            v
       NORMALIZATION
            |
            v
       FEED-FORWARD
            |
            v
       RESIDUAL PATH
            |
            v
       NORMALIZATION
            |
            v
          OUTPUT

This diagram illustrates a common post-normalization architecture; verify the actual ordering in the installed EveryO implementation.

15.2 Recommended Tests

  • Shape consistency.
  • Attention masking where supported.
  • Positional encoding behavior.
  • Forward correctness.
  • Gradient correctness.

15.3 Exercise

Build a small sequence encoder using documented EveryO components and compare its output dimensions across sequence lengths.


16. Advanced Training Pipelines

EveryO provides a Trainer abstraction.

16.1 Example

import everyo as eo

model = eo.Sequential(
    eo.Linear(4, 16),
    eo.ReLU(),
    eo.Linear(16, 2),
)

optimizer = eo.Adam(
    model.parameters(),
    lr=0.001,
)

loss_fn = eo.CrossEntropyLoss()

trainer = eo.Trainer(
    model,
    optimizer,
    loss_fn,
    metrics=["accuracy"],
)

history = trainer.fit(
    train_loader,
    epochs=10,
    validation_loader=validation_loader,
)

The training and validation loaders must be created before running this example.

16.2 Recommended Workflow

         DATASET
            |
            v
        DATALOADER
            |
            v
           MODEL
            |
            v
         FORWARD
            |
            v
           LOSS
            |
            v
         BACKWARD
            |
            v
       OPTIMIZER STEP
            |
            v
         VALIDATION
            |
            v
        CHECKPOINT

16.3 Monitoring

Track:

  • Training loss.
  • Validation loss.
  • Accuracy or other relevant metrics.
  • Learning rate.
  • Gradient stability.

17. Gradient Clipping

Gradient clipping helps control excessively large gradient updates.

17.1 Norm-Based Clipping

For a gradient vector (g):

[ g_{\text{clipped}}= g\cdot \min\left(1,\frac{c}{|g|}\right) ]

where (c) is the maximum norm.

17.2 When It May Help

  • Recurrent networks.
  • Deep architectures.
  • Training with unstable gradients.

17.3 Best Practice

Measure gradient norms before choosing clipping thresholds.

17.4 Exercise

Compare training with and without clipping on a deliberately challenging sequence task.


18. Learning Rate Scheduling

Learning rate scheduling changes the learning rate during training.

18.1 Common Strategies

  • Step decay.
  • Exponential decay.
  • Plateau-based reduction.
  • Cosine scheduling.

These are general strategies; verify which are supported by the installed EveryO version.

18.2 Example Formula

Exponential decay:

[ \eta_t=\eta_0\gamma^t ]

where:

  • (\eta_0): Initial learning rate.
  • (\gamma): Decay factor.
  • (t): Schedule step.

18.3 Exercise

Compare a constant learning rate against a supported scheduling strategy.


19. Early Stopping

Early stopping can reduce unnecessary training after validation performance stops improving.

19.1 Typical Configuration

  • Monitored metric.
  • Improvement direction.
  • Patience.
  • Minimum improvement.

19.2 Example Logic

       TRAIN EPOCH
            |
            v
       VALIDATE MODEL
            |
            v
       METRIC IMPROVED?
         /        \
       YES         NO
        |           |
        v           v
    SAVE BEST    INCREMENT
      STATE       PATIENCE
                    |
                    v
               LIMIT REACHED?
                 /       \
               NO         YES
               |           |
               v           v
            CONTINUE      STOP

19.3 Best Practice

Use a held-out validation set and document the stopping criterion.


20. Checkpointing and Serialization

EveryO supports .evo model archives.

20.1 Save

import everyo as eo

eo.save(model, "advanced_model.evo")

20.2 Restore

restored_model = eo.load(
    "advanced_model.evo"
)

20.3 Recommended Validation

Compare outputs from the original and restored models on identical inputs.

20.4 Archive Format

The documented .evo archive uses:

model.evo
|
+-- manifest.json
|
+-- parameters.npz

20.5 Security

The format avoids Python pickle execution, but untrusted archives still require careful handling.


21. Mixed Precision

EveryO provides mixed-precision utilities.

21.1 Purpose

Mixed precision combines lower-precision operations with higher-precision state where appropriate.

21.2 Benefits and Trade-Offs

Potential benefits:

  • Reduced memory usage.
  • Faster supported operations on suitable hardware.

Potential risks:

  • Underflow.
  • Overflow.
  • Numerical differences.
  • No CPU speed improvement.

21.3 Example Program

python examples/mixed_precision.py

21.4 Exercise

Compare float32 and mixed-precision execution on a supported model.

Report both runtime and numerical error.


22. CUDA Acceleration

CUDA is optional in EveryO.

22.1 Availability Check

import everyo as eo

print(eo.cuda.is_available())

22.2 Strict Device Selection

import everyo as eo

device = eo.device(
    "cuda",
    strict=True,
)

Strict mode requires CUDA to be available.

22.3 Device Transfer

EveryO documents GPU-resident tensor utilities under eo.cuda.

22.4 Limitations

GPU-resident operations support selected functionality and should not be assumed to provide general autograd integration.

22.5 Exercise

Benchmark a supported operation on CPU and CUDA.

Include host-device transfer time in an end-to-end comparison.


23. Distributed Training

EveryO includes experimental process-based distributed training functionality.

23.1 Repository Example

python examples/distributed_training.py

23.2 Key Concepts

  • Worker process.
  • Process rank.
  • World size.
  • Gradient synchronization.
  • Communication overhead.

23.3 Validation

Compare distributed results against a single-process reference.

23.4 Security

The documented TCP communication implementation assumes a trusted network.

23.5 Limitation

Successful same-host testing does not establish reliable cross-machine behavior.


24. ONNX Export

EveryO provides ONNX interoperability for supported models.

24.1 Install Dependencies

python -m pip install -e ".[onnx]"

24.2 Example

import everyo as eo

model = eo.Sequential(
    eo.Linear(4, 8),
    eo.ReLU(),
    eo.Linear(8, 2),
)

model.eval()

eo.export_onnx(
    model,
    "advanced_model.onnx",
    input_shape=(1, 4),
)

24.3 Repository Example

python examples/onnx_export.py

24.4 Validation

Run the exported model through ONNX Runtime and compare outputs.

24.5 Tracing Caveat

Traced models may encode fixed control-flow or sequence-length assumptions.


25. Quantization

EveryO includes dynamic quantization utilities.

25.1 Purpose

Quantization reduces the precision of stored numerical values.

25.2 Model Size

For an idealized weight-only comparison:

float32 weight = 4 bytes

int8 weight = 1 byte

This suggests a potential reduction in raw weight storage, excluding metadata and other model components.

25.3 Important Limitation

EveryO does not document specialized faster int8 execution kernels for its dynamic quantization implementation.

25.4 Exercise

Compare original and quantized model outputs and serialized sizes.


26. Profiling and Optimization

EveryO provides profiling utilities.

26.1 Profiling Example

import everyo as eo

with eo.profile() as profiler:
    output = model(input_tensor)

print(profiler.summary())

The model and input tensor must be defined beforehand.

26.2 Profiling Objectives

Identify:

  • Expensive operations.
  • Repeated computations.
  • Memory-intensive stages.
  • Unexpected bottlenecks.

26.3 Optimization Sequence

        PROFILE
           |
           v
     FIND BOTTLENECK
           |
           v
      VERIFY CAUSE
           |
           v
       APPLY CHANGE
           |
           v
     TEST CORRECTNESS
           |
           v
       BENCHMARK
           |
           v
      DOCUMENT RESULT

26.4 Best Practice

Do not optimize based solely on assumptions.


27. Reproducible Experiments

27.1 Record Environment

python -m pip freeze > requirements-lock.txt

27.2 Record Commit

git rev-parse HEAD

27.3 Example Experiment Metadata

experiment:
  name: advanced-classifier
  framework: EveryO

model:
  architecture: multilayer-perceptron
  input_features: 8
  hidden_features: 32
  output_features: 3

training:
  optimizer: adam
  learning_rate: 0.001
  epochs: 10
  batch_size: 32

evaluation:
  metric: accuracy

environment:
  device: cpu
  seed: 42

This is a suggested record format, not a required EveryO configuration schema.

27.4 Best Practice

Store:

  • Configuration.
  • Metrics.
  • Model checkpoints.
  • Software versions.
  • Relevant logs.

28. Debugging Advanced Models

28.1 Common Problems

Problem Possible Cause Recommended Action
Shape mismatch Incorrect dimensions Inspect tensor shapes
Missing gradients Broken gradient path Verify autograd
NaN loss Numerical instability Inspect inputs and learning rate
Slow training Computational bottleneck Profile execution
CUDA unavailable Missing hardware or extension Run diagnostics
ONNX mismatch Unsupported or shape-sensitive export Compare outputs
Serialization error Unsupported module or invalid archive Verify registration and file
Overfitting Excessive model complexity Validate regularization

28.2 Recommended Diagnostic Commands

everyo doctor

python -m pytest -q

ruff check .

28.3 Debugging Strategy

Reduce a failing model to the smallest architecture that reproduces the issue.


29. Advanced Exercises

Exercise 1 — Gradient Verification

Build a small computation graph and compare analytical gradients with finite differences.

Deliverable: Numerical error report.

Exercise 2 — Custom Architecture

Build a reusable neural network module using documented EveryO abstractions.

Deliverable: Module implementation and tests.

Exercise 3 — CNN Experiment

Run the repository convolutional network example.

Deliverable: Input/output shape analysis and training results.

Exercise 4 — Sequence Modeling

Compare RNN, LSTM, and GRU architectures.

Deliverable: Evaluation table and reproducible configuration.

Exercise 5 — Attention Analysis

Inspect attention scores and verify their normalization.

Deliverable: Mathematical explanation and numerical tests.

Exercise 6 — ONNX Validation

Export a supported model and compare EveryO and ONNX Runtime outputs.

Deliverable: Absolute and relative error report.

Exercise 7 — Performance Profiling

Profile a model and identify its most expensive operations.

Deliverable: Profiling summary and optimization proposal.

Exercise 8 — Serialization Round Trip

Save and reload a supported model.

Deliverable: Parameter and prediction equivalence test.


30. Learning Roadmap

Stage 1 — Numerical Foundations

Focus: Tensor operations and gradients.

Completion criteria:

  • Understand tensor shapes.
  • Validate matrix multiplication.
  • Derive simple gradients.
  • Implement finite-difference checks.

Stage 2 — Neural Network Engineering

Focus: Model architectures.

Completion criteria:

  • Build an MLP.
  • Run a CNN example.
  • Understand normalization.
  • Validate model outputs.

Stage 3 — Sequence and Attention

Focus: Advanced architectures.

Completion criteria:

  • Run recurrent model examples.
  • Explain LSTM and GRU.
  • Understand scaled dot-product attention.
  • Validate sequence shapes.

Stage 4 — Training and Reliability

Focus: Reproducible experiments.

Completion criteria:

  • Configure a training pipeline.
  • Monitor validation metrics.
  • Save checkpoints.
  • Verify restored outputs.

Stage 5 — Acceleration and Interoperability

Focus: Optional advanced capabilities.

Completion criteria:

  • Understand CUDA availability.
  • Evaluate mixed precision.
  • Export a supported ONNX model.
  • Compare numerical outputs.
  • Profile performance.

31. Official Resources

Resource Link
EveryO Repository GitHub
README README.md
Example Programs examples/
API Reference API Reference Wiki
Tensor Engine Tensor Engine Wiki
Automatic Differentiation Autograd Wiki
Neural Networks Neural Networks Wiki
Model Training Model Training Wiki
Benchmarking Benchmarking Guide
Numerical Validation Numerical Accuracy and Validation
Contributing CONTRIBUTING.md
Support SUPPORT.md
NumPy numpy.org
ONNX onnx.ai

Advanced Tutorials — Documentation Prepared

Next Recommended Page: Custom Modules and Layers →

Home · Examples and Tutorials · API Reference


EveryO — Open Machine Learning. Built for Developers.

Project Maintainer: @krishanth7

Open Source · MIT Licensed · Community Driven

© 2026 EveryO Contributors

Clone this wiki locally