ContentsFoundations to FrontierBezhig

graduate_code/starters/neural.py

All lab code. Download this file.

# Exercise scaffold. Reference implementation is in a separate directory.
"""G13: one-hidden-layer tanh network, flat parameters, analytic backpropagation."""
import math
import random
try:
    from .ml import validate_xy, sigmoid, logit_loss
except ImportError:
    from ml import validate_xy, sigmoid, logit_loss

def initialize(d=2, h=2, seed=7):
    raise NotImplementedError('Implement this contract from the book.')

def loss_grad(theta, X, y, h=2, lam=0.0):
    raise NotImplementedError('Implement this contract from the book.')

def gradient_check(theta, X, y, h=2, lam=0.03, step=1e-06):
    raise NotImplementedError('Implement this contract from the book.')