Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Training a small neural network using JAX and gradient descent.
import jax.numpy as jnp
from jax import grad
# Data
X = jnp.array([[1.0],[2.0],[3.0],[4.0]])
y = jnp.array([2.0,4.0,6.0,8.0])
# Parameters
w = 0.0
b = 0.0
# Prediction
def predict(w, b, X):
return w * X + b
# Loss
def loss(w, b):
y_pred = predict(w, b, X)
return jnp.mean((y - y_pred)**2)
grad_loss = grad(loss, argnums=(0,1))
# Gradient descent
for _ in range(1000):
dw, db = grad_loss(w, b)
w -= 0.01 * dw
b -= 0.01 * db
print('Learned w,b:', w, b)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.