Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Performing multi-class classification using softmax in JAX.
import jax.numpy as jnp
from jax import grad
# Data
X = jnp.array([[1,2],[3,4],[5,6]])
y = jnp.array([0,1,2])
# Parameters
W = jnp.zeros((3,2))
b = jnp.zeros(3)
# Softmax
def softmax(z):
e_z = jnp.exp(z - jnp.max(z))
return e_z / e_z.sum(axis=0)
# Loss
def loss(W, b):
logits = jnp.dot(X, W.T) + b
y_pred = jnp.array([softmax(l) for l in logits])
return -jnp.mean(jnp.log(y_pred[jnp.arange(len(y)), y]))
grad_loss = grad(loss, argnums=(0,1))JAX is an open-source Python library for high-performance numerical computing, combining NumPy-like API with automatic differentiation (autograd), GPU/TPU acceleration, and composable function transformations for machine learning and scientific computing.
Origin & Creator
JAX was developed by researchers at Google Research starting in 2018, building on Autograd and XLA (Accelerated Linear Algebra) to enable high-performance, differentiable programming.
Industrial Note
JAX is widely used in cutting-edge machine learning research, physics simulations, reinforcement learning, and differentiable programming, where composable gradients and hardware acceleration are essential.