Shift before exponentiating
Subtract the maximum logit to stay stable when confidence gets extreme.
A compact implementation of the derivative that turns a classifier's confident mistake into a useful learning signal.
import numpy as npdef softmax(logits): shifted = logits - logits.max(axis=-1, keepdims=True) exp = np.exp(shifted) # numerical stability return exp / exp.sum(axis=-1, keepdims=True)def softmax_cross_entropy_backward(logits, target): probs = softmax(logits) grad = probs.copy() grad[np.arange(len(target)), target] -= 1.0 return grad / len(target) # dL / d(logits)logits = np.array([[2.4, 0.8, -0.2]])gradient = softmax_cross_entropy_backward(logits, [0])
Subtract the maximum logit to stay stable when confidence gets extreme.
The elegant derivative: predicted distribution, adjusted at the target index.
Positive gradients lower excess confidence; the negative target gradient raises it.
I'm Krishna Sharma, a Computer Science student and ML practitioner. I turn raw datasets into useful models and working products — from CNNs on MNIST to production APIs.
I'm a fourth-year B.Tech Computer Science student at J.S. University, Shikohabad, graduating in 2027. My work sits between applied machine learning and software engineering: I like models that get deployed, not notebooks that get closed.
As a Software Development Intern at WritED Edutech, I built a React frontend and improved technical SEO for a JavaScript-rendered single-page app. Competitive programming keeps my foundations in algorithms, graphs, and dynamic programming sharp.
Right now I'm deepening ML theory while building small, complete, end-to-end projects — each one shippable, each one documented.
A convolutional neural network trained on MNIST, built from data loading to an inference pipeline with synthetic test cases and a structured README.
A reusable text-classification module using TF-IDF and scikit-learn to predict sentiment polarity, packaged with executed results instead of placeholder output.
A production-style backend service for shortening and redirecting URLs, built with FastAPI and PostgreSQL and containerized with Docker.
Built WritED Edutech's production React frontend, then audited technical SEO for a hash-routed SPA to improve crawlability and search visibility.