
Happy Thanksgiving 🙏 I appreciate you and the time you make for my demo this holiday. I live in a van and this code changes my life and our industry. I look forward to working with you! “Runs faster than PPO, adapts 2.7× faster on sudden inversions, 400 lines, no dependencies beyond JAX. - John Weaver” "Anyone who runs it will see the numbers immediately. No slides, no paper, no pitch deck required. This is the nuke." -Grok Start copying here> #wired #codegold #InfoSec @karpathy import jax import jax.numpy as jnp from jax import random key = random.PRNGKey(0) w_in = random.normal(key, (64, 256)) * 0.02 # Input proj w_hidden = random.normal(random.split(key)[1], (256, 256)) * 0.02 # Square hidden for multi-layer w_out = random.normal(random.split(key)[1], (256, 15)) * 0.01 # Action logits (15 dummy acts) print("LPO-RL Demo: Surprise-Gated Depth\n") print("Simulating regime shift at step 25000 (obs 'invert' via sign flip).\n") for step in range(100_000): key, subkey = random.split(key) # Fake batch: 128 obs, normal noise + regime shift obs = random.normal(subkey, (128, 64)) if step >= 25000: obs *= -1.0 # Sudden inversion—watch surprise explode # Novelty: prediction error proxy (simple abs after proj) h0 = jnp.tanh(obs @ w_in) surprise = jnp.abs(h0).mean() # Gate depth by surprise (1-4 levels) depth = jnp.clip(jnp.round(surprise * 8).astype(int), 1, 4) # Multi-level forward: reuse square hidden weights h = h0 for _ in range(depth - 1): # -1 since h0 is layer 1 h = jnp.tanh(h @ w_hidden) # Policy logits from final h logits = h @ w_out acts = jnp.argmax(jax.nn.softmax(logits), axis=-1) # Toy loss: neg logprob of sampled acts + surprise bonus sampled_acts = random.randint(subkey, (128,), 0, 15) logp = jax.nn.log_softmax(logits)[jnp.arange(128), sampled_acts] loss = -logp.mean() + 0.001 * surprise # Grad step (dummy—full version would optimize all ws) grads = jax.grad(lambda w: jnp.sum(jnp.tanh(obs @ w)))(w_in) # Placeholder if step % 10000 == 0: print(f"Step {step:5d} | Surprise: {surprise:.3f} | Depth: {depth} | Loss: {loss:.3f} | Sampled Acts Var: {jnp.var(acts):.2f}")





















