<s> import numpy as np <EOL> import numpy . random as npr <EOL> import sys <EOL> sys . path . append ( '<STR_LIT:..>' ) <EOL> import kayak <EOL> N = <NUM_LIT> <EOL> D = <NUM_LIT:5> <EOL> P = <NUM_LIT:3> <EOL> learn = <NUM_LIT> <EOL> batch_size = <NUM_LIT> <EOL> X = npr . randn ( N , D ) <EOL> true_W = npr . randn ( D , P ) <EOL> Y = np . dot ( X , true_W ) + <NUM_LIT:0.1> * npr . randn ( N , P ) <EOL> kyk_batcher = kayak . Batcher ( batch_size , N ) <EOL> kyk_inputs = kayak . Inputs ( X , kyk_batcher ) <EOL> kyk_targets = kayak . Targets ( Y , kyk_batcher ) <EOL> W = <NUM_LIT> * npr . randn ( D , P ) <EOL> kyk_W = kayak . Parameter ( W ) <EOL> kyk_out = kayak . MatMult ( kyk_inputs , kyk_W ) <EOL> kyk_el_loss = kayak . L2Loss ( kyk_out , kyk_targets ) <EOL> kyk_loss = kayak . MatSum ( kyk_el_loss ) <EOL> for ii in xrange ( <NUM_LIT:100> ) : <EOL> for batch in kyk_batcher : <EOL> loss = kyk_loss . value <EOL> print loss , np . sum ( ( kyk_W . value - true_W ) ** <NUM_LIT:2> ) <EOL> grad = kyk_loss . grad ( kyk_W ) <EOL> kyk_W . value -= learn * grad </s>
