0% loading

AINO

Deep Learning NumPy NLP

A fully deep learning deep learning micro library forged from pure mathematics, raw curiosity, and a deeply personal refusal to let “it just works” be a good enough answer.

AINO Architecture

There is a particular kind of frustration that only the curious can feel — the frustration of using a tool you don’t fully understand. Most programmers learn machine learning the same way: they install a library, call a function, watch a number go up, and call it done. The abstraction handles everything. The abstraction hides everything. For a long time, I did the same. Then I watched a lecture that changed everything.

MIT 6.S191: Introduction to Deep Learning. The slides were clean, the math was dense, and somewhere between the derivations and the diagrams, something shifted in me. I didn’t want to be a user of neural networks anymore. I wanted to be an architect of them — to understand not just what they do, but why they do it, and how every single multiplication, every subtle curve in an activation function, every cascading gradient conspires to make a machine learn. That obsession became AINO — Aino Is Neural Operation.


The first question I asked myself was simple: where do you even begin? The answer seemed obvious — biology. The brain is made of neurons. So I built neurons. I created a class Perceptron for every computational unit in the network, each instance proudly owning its own weight vector and bias term, each one communicating with the next through method calls and object references. It looked exactly like the diagrams in textbooks. It felt deeply, satisfyingly correct.

It was also catastrophically slow.

Training a modest network on a toy dataset took 32 full minutes. Thirty-two minutes of watching a progress bar crawl, of hearing the CPU fan spin furiously while actual computation did almost nothing useful. The processor wasn’t spending its time on matrix math — it was spending it on Python overhead. On object instantiation, on attribute lookup, on the sheer bureaucratic cost of a thousand tiny objects taking turns to speak. I had built the most biologically faithful neural network I could imagine, and it was being strangled by its own elegance.

The breakthrough came not from adding more code, but from thinking differently about what computation actually is. A layer of neurons isn’t a collection of individual beings — it’s a transformation. A function that takes an input vector and produces an output vector. And that transformation, in its entirety, can be expressed as a single operation: np.dot(W, X) + b. One line. One matrix multiply. No loops, no objects, no turn-taking.

I deleted class Perceptron. I moved everything into layer.py as pure vectorized logic. And the moment I did, something remarkable happened — the computation dropped from Python’s interpreted world down into C-level SIMD execution, where modern CPUs process entire chunks of data in parallel using hardware-level instructions that Python programmers almost never touch directly. The training time collapsed from 32 minutes to 19 seconds. Not 20. Not 25. Nineteen. I ran it three times just to believe it. The lesson was carved into me permanently: the fastest code is almost always the most mathematically honest code.

AINO Architecture


Speed, however, is meaningless if the network can’t learn. Learning in a neural network means one thing: backpropagation — the algorithm that measures error at the output and flows it backward through every layer, adjusting weights in proportion to their contribution to that error. Most practitioners treat this as a black box they trust entirely to their framework. I had no framework. I had only a whiteboard, a calculus textbook, and time.

I derived the Chain Rule by hand for every activation function I planned to use. For Sigmoid: how a small change in the weighted input produces a proportional change in the output, attenuated by the curve’s slope at that point. For ReLU: the brutal simplicity of passing the gradient through unchanged if the neuron was active, and killing it completely if it wasn’t. For Tanh: the elegant symmetry of a function centered at zero, better behaved than Sigmoid but carrying its own vanishing gradient risks at the extremes. Each derivation wasn’t just mathematics — it was understanding. Understanding why certain architectures explode, why others go quiet, why learning rate isn’t just a hyperparameter but a statement about how much you trust your own gradient.

Beyond mathematics, I built AINO’s agnostic hardware backend — a runtime detection system that profiles the available compute environment on startup. On a standard machine, AINO runs with NumPy arrays laid out in contiguous memory blocks, maximizing cache efficiency and CPU throughput. On a machine with an NVIDIA GPU, AINO silently switches its entire numerical backend to CuPy — a NumPy-compatible library that executes the same operations on GPU cores, unlocking thousands of parallel threads at once. The crucial detail: not a single line of the architecture code changes. The same layer.py, the same backpropagation logic, the same training loop — all of it migrates to GPU automatically. Hardware-agnostic by design. Scalable by default.


With a fast, learning-capable, hardware-aware framework in hand, I needed a problem worthy of it. I chose chess.

It was, perhaps, an act of hubris. Chess is not a pattern recognition task — it is a combinatorial explosion of causality, where a move made now creates consequences 15 moves into the future, where the value of a position cannot be assessed locally, and where even grandmasters disagree on the evaluation of complex endgames. I built a Monte Carlo Tree Search from scratch: a probabilistic algorithm that explores the game tree by simulating random playouts, balancing exploration of unknown branches with exploitation of promising ones. I coupled it with a Dual-Head Neural Network — one head predicting the probability distribution over legal moves, the other predicting the scalar value of a board position. An architecture inspired directly by AlphaZero, reduced to first principles and implemented entirely in AINO.

To make the AI care about material, I added a Hybrid Material Calculator — an explicit scoring function that weighted pieces by their classical values, intended to give the neural network a grounding signal for what it meant to be “winning.” The system could play. It could calculate. And then, in a test game, it walked into a Fool’s Mate — the most elementary checkmate pattern in chess, exploitable in four moves by any beginner.

The post-mortem was clarifying. The problem wasn’t computation — it was representation. Chess boards have spatial structure: the relationship between two squares depends not just on their pieces but on their coordinates, their diagonals, the corridors of open files between them. A flat vector representation, fed into fully connected layers, loses this geometry entirely. The horizon effect in MCTS meant the network couldn’t see far enough ahead to recognize the threat forming. The material calculator gave the engine a vocabulary for value, but no grammar for danger. I had built something that could think, but not something that could truly see.

Losing to a Fool’s Mate was the most educational moment in the entire project. It forced a serious reckoning with the relationship between problem structure and model architecture — a lesson that no textbook ever teaches as efficiently as a four-move checkmate does.


I pivoted to language. Specifically, to the question of whether a neural network trained entirely from scratch — with no pre-trained embeddings, no transformer attention, no LSTM memory, no borrowed intelligence — just raw numbers and gradient descent — could learn to distinguish a joyful film review from a devastated one.

The dataset: IMDb’s 50,000 movie reviews, split evenly between positive and negative sentiment. The encoding: TF-IDF vectorization — a technique that transforms each review into a sparse vector of 5,000 dimensions, where each dimension represents a word weighted by how distinctive it is across the entire corpus. Common filler words like “the” and “is” collapse toward zero. Rare but emotionally loaded words like “masterpiece” and “unwatchable” become sharp, discriminating signals. Language, reduced to geometry.

My first architecture was ambitious: [5000 → 512 → 128 → 1] — three hidden layers of gradually decreasing width, designed to compress the high-dimensional input into an increasingly abstract representation before making a binary judgment. In theory, deeper should mean richer. In practice, it meant vanishing gradients. TF-IDF vectors are extraordinarily sparse — the vast majority of entries in any given review vector are zero. As these near-zero activations passed through successive non-linearities, their gradients shrank with every layer. By the time the signal reached the earliest weights, it was too faint to produce meaningful updates. The network stagnated. Accuracy bounced between 50 and 76%, barely better than random, despite training on tens of thousands of carefully labeled examples.

The solution demanded abandoning the assumption that deeper is always better. I stripped the architecture to almost nothing: [5000 → 64 → 1]. One hidden layer of 64 neurons. It sounds almost insultingly simple. But the mathematics is sound — a single sufficiently wide hidden layer is a universal function approximator, and 5,000-dimensional TF-IDF space, despite its sparsity, carries enough signal to be meaningfully separated with the right learned linear transformation. With an aggressive learning rate and GPU acceleration powering through the data, AINO processed all 40,000 training reviews in seconds per epoch. The accuracy climbed steadily, confidently, and settled at 88.88%.

AINO could understand human emotion. Not perfectly — no model trained this way ever is — but reliably, consistently, at a level that rivals implementations built on established frameworks, achieved entirely by a single engineer who derived every gradient, implemented every layer, and debugged every numerical instability from absolute zero.


A framework that only runs in one session on one machine isn’t a framework — it’s a script. The final engineering challenge was persistence: how do you save the “brain” of a neural network in a way that faithfully captures the trained weights, the architecture metadata, and the backend-specific memory layout, and then reconstruct it perfectly on a different machine with potentially different hardware?

I designed a custom serialization format: .dit — a structured binary format that encodes layer configurations, weight tensors, activation function identifiers, and device provenance into a single portable file. Loading a .dit model on a CPU machine from a network trained on GPU requires no manual conversion, no format negotiation, no code changes. The format handles it transparently. The brain survives the transfer.

With the framework complete, tested, and portable, I published it. AINO is now available on PyPI — installable by anyone on earth with a single command: pip install aino. The GitHub repository carries production-grade documentation: a README written to the standards of real open-source projects, benchmarks highlighting the 32-minute-to-19-second optimization arc, and clear API references for the layer, activation, loss, and training modules.

To validate the core research and contribute something back to the community, I published a full experimental notebook on Kaggle: “Sentiment Analysis from Scratch: Evaluating Deep vs. Shallow Architectures” — a structured, reproducible comparison of the two architectural approaches with tracked metrics, annotated loss curves, and honest architectural post-mortems. It exists not just as a portfolio piece, but as documentation of a real engineering process, one where the failure of the deep model is as instructive as the success of the shallow one.


AINO is not TensorFlow. It is not PyTorch. It never tried to be. What AINO is, precisely, is proof — that the machinery underneath modern artificial intelligence is not magic, not inaccessible, not the exclusive domain of research labs with PhD teams and supercomputer budgets. It is mathematics. Linear algebra. Calculus. Patient, careful engineering applied one derivative at a time.

And if you are willing to derive it yourself — to feel every gradient flow backward through code you wrote line by line, to debug a vanishing activation at 2 AM, to delete an entire class hierarchy and replace it with a single matrix multiply, to lose a chess game in four moves and understand exactly why — then you don’t just use AI.

You understand it. Completely. From the inside.

That understanding is what AINO is built from. Every single line of it.

W.
Logo

© 2026 Raditya Alfarisi

Github LinkedIn Instagram Kaggle Chess.com