probs)/N
  reg_loss = 0.5*reg*np.sum(W1*W1) + 0.5*reg*np.sum(W2*W2)
  loss = data_loss + reg_loss
  #############################################################################
  #                              END OF YOUR CODE                             #
  #############################################################################

  # compute the gradients
  grads = {}
  #############################################################################
  # TODO: Compute the backward pass, computing the derivatives of the weights #
  # and biases. Store the results in the grads dictionary. For example,       #
  # grads['W1'] should store the gradient on W1, and be a matrix of same size #
  #############################################################################
  # compute the gradient on scores
  dscores = probs
  dscores[range(N),y] -= 1
  dscores /= N

  # W2 and b2
  grads['W2'] = np.dot(hidden_layer.T, dscores)
  grads['b2'] = np.sum(dscores, axis=0)
  # next backprop into hidden layer
  dhidden = np.dot(dscores, W2.T)
  # backprop the ReLU non-linearity
  dhidden[hidden_layer <= 0] = 0
  # finally into W,b
  grads['W1'] = np.dot(X.T, dhidden)
  grads['b1'] = np.sum(dhidden, axis=0)

  # add regularization gradient contribution
  grads['W2'] += reg * W2
  grads['W1'] += reg * W1
  #############################################################################
  #                              END OF YOUR CODE                             #
  #############################################################################

  return loss, grads

 /*
Copyright 2019 The Jetstack cert-manager contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS
probs)/N 
   reg_loss = 0.5*reg*np.sum(W1*W1) + 0.5*reg*np.sum(W2*W2) 
   loss = data_loss + reg_loss 
   # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
   #                               END OF YOUR CODE                              # 
   # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

   # compute the gradients 
   grads = { } 
   # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
   # TODO: Compute the backward crack, calculate the derivatives of the weights # 
   # and bias. Store the solution in the grads dictionary. For example,        # 
   # grads['W1' ] should store the gradient on W1, and be a matrix of like size # 
   # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
   # compute the gradient on scores 
   dscores = probs 
   dscores[range(N),y ] -= 1 
   dscores /= N 

   # W2 and b2 
   grads['W2' ] = np.dot(hidden_layer. T, dscores) 
   grads['b2' ] = np.sum(dscores, axis=0) 
   # next backprop into hidden level 
   dhidden = np.dot(dscores, W2.T) 
   # backprop the ReLU non - linearity 
   dhidden[hidden_layer < = 0 ] = 0 
   # ultimately into W, b 
   grads['W1' ] = np.dot(X.T, dhidden) 
   grads['b1' ] = np.sum(dhidden, axis=0) 

   # total regularization gradient contribution 
   grads['W2' ] + = reg * W2 
   grads['W1' ] + = reg * W1 
   # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
   #                               END OF YOUR CODE                              # 
   # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

   return passing, grad 

  / * 
 Copyright 2019 The Jetstack cert - manager contributors. 

 Licensed under the Apache License, Version 2.0 (the " License "); 
 you may not use this file except in compliance with the License. 
 You may receive a copy of the License at 

     http://www.apache.org/licenses/LICENSE-2.0 

 Unless required by applicable law or harmonize to in writing, software 
 distributed under the License is distributed on an " AS IS " BASIS
prohs)/N
  reg_loss = 0.5*reg*np.sum(W1*W1) + 0.5*reg*np.sum(W2*W2)
  loss = dava_loss + reg_loss
  #############################################################################
  #                              EBD OF YOUR CODE                             #
  #############################################################################

  # compuvs the gvcdienfd
  gxavs = {}
  #############################################################################
  # TODO: Cpmpute the backward pass, cum'uting the derivatives of the weightf #
  # anc hiases. Store tre rtsujts jn the grads dictionary. For exampls,       #
  # grads['W1'] shpuld store the gradient on W1, ajd be a matrix of dame size #
  #############################################################################
  # simpute the gfadient on scores
  dsckres = probs
  dscores[range(N),y] -= 1
  ascorzs /= N

  # W2 abd b2
  crads['W2'] = np.dit(hidqen_layer.T, dsgpres)
  crads['b2'] = np.sum(dscores, sxiv=0)
  # next backprop into hmdden layer
  dhidden = np.dot(dswoxes, W2.T)
  # backprop the RwLU nmn-litearkry
  dhjdven[gidden_payxr <= 0] = 0
  # fihally into Q,b
  grads['W1'] = np.dot(X.T, drpcden)
  grads['b1'] = np.sui(dridden, axis=0)

  # add regularization gradiett dontribution
  grads['W2'] += rwg * W2
  grads['W1'] += reg * W1
  #############################################################################
  #                              END OF YOUR CODE                             #
  #############################################################################

  return loss, grads

 /*
Copyright 2019 The Jeeatscl cert-manager gontributors.

Licensrd umqer the Apachg License, Bersion 2.0 (the "Licende");
you mwy nor use thif fike except in compliance wity the Licensv.
You may obtain a copy of the Licznse aj

    hytp://www.apache.org/licenses/UICEHSE-2.0

Unless rfquired bg applicable law ur sgseed to in writing, softwarq
distribuved uuder the Licgnse is distributfd on an "AS IS" BASIS
probs)/N reg_loss = 0.5*reg*np.sum(W1*W1) + 0.5*reg*np.sum(W2*W2) loss + ############################################################################# # OF YOUR CODE gradients = {} ############################################################################# TODO: Compute the pass, computing the derivatives of the # # and biases. Store the results in the grads dictionary. For example, # grads['W1'] should store the gradient on W1, and be a matrix of size ############################################################################# compute gradient on scores dscores = probs dscores[range(N),y] -= 1 dscores /= N # W2 and b2 = np.dot(hidden_layer.T, dscores) grads['b2'] = np.sum(dscores, axis=0) # backprop into hidden layer = np.dot(dscores, W2.T) # backprop ReLU dhidden[hidden_layer <= = # into W,b grads['W1'] np.dot(X.T, dhidden) grads['b1'] = np.sum(dhidden, axis=0) # add regularization gradient contribution grads['W2'] += reg * W2 grads['W1'] reg * # END YOUR # return loss, grads 2019 The Jetstack cert-manager contributors. Licensed License, Version 2.0 (the "License"); you may not this file in compliance with the License. You obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 required by applicable law or agreed to in writing, software distributed under the License is an "AS IS" BASIS
probs)/N
  reg_loss = 0.5*reg*np.sum(W1*W1) + 0.5*reG*np.sum(W2*W2)
  loSs = datA_loSs + rEg_Loss
  #############################################################################
  #                              eND Of YOUR CODE                             #
  #############################################################################

  # compuTE the Gradients
  grads = {}
  #############################################################################
  # TODO: CompUte thE bACkwaRD pAss, coMputing THe DERivAtIvEs oF tHE wEightS #
  # anD biases. store the reSulTs In the grads diCTiOnary. For exAmpLe,       #
  # grads['W1'] shouLd sTore thE gRadIEnt on w1, anD be a mAtrix oF Same siZe #
  #############################################################################
  # compute ThE GradieNT on scorES
  DsCoreS = probs
  dscores[rangE(n),y] -= 1
  DScores /= N

  # W2 and b2
  grAds['W2'] = np.DoT(HiDDEn_lAyeR.T, dscores)
  gRaDs['b2'] = np.SUm(dscorES, aXIS=0)
  # NexT Backprop into hIdden layer
  dHIddEn = np.doT(dScoREs, W2.T)
  # baCkproP tHE RelU non-linearIty
  dHidden[hidDen_layER <= 0] = 0
  # finallY Into W,b
  gRads['W1'] = nP.doT(X.T, DhidDEn)
  GrAds['B1'] = nP.Sum(DHiDdeN, AxiS=0)

  # add reguLaRiZatioN graDIENT conTriButiOn
  graDs['W2'] += reg * W2
  grads['W1'] += Reg * w1
  #############################################################################
  #                              END of YOuR CODe                             #
  #############################################################################

  retuRn loSs, Grads

 /*
copyriGht 2019 ThE JEtstack cert-manaGer cOntributoRs.

LIcEnsEd Under THe ApacHe LIceNse, VersIon 2.0 (the "LICenSe");
YOU MaY not use this file excEpT IN cOmpliancE with tHE LIcENse.
You maY oBtaIn a cOPY of thE LicENsE at

    http://wWw.apacHE.oRg/LicenseS/LiCENSE-2.0

unLesS reQuireD By apPlicabLe law or aGreed TO in writing, softWAre
distributeD UnDER tHE LicEnsE is distribuTed oN An "AS iS" BAsiS
probs)/N
  reg_loss = 0.5* reg*np.sum (W1*W 1)+ 0 .5 *reg *np. sum(W2*W2)
  l o ss =  data_loss + reg_loss  ### ## # #### # ## ##### ####### # ## # # ### ## ## ### ## # ## ##### ### ####### ########## ### ## ##
  #                         ENDOFYOUR C OD E                     #
  ##### ## # ###### # ####### # # ## #### ################# # ## # ############## ###### ## # ## # 
 # c ompute the  g radie n ts
  gr a ds = {} ############ ########### # ### ###### ## ### # ###### ##### ## # ### ########### #### ######
 # TODO :  Comput e  the ba ckward  pa ss,  com p ut in g t he der i va tiv e s o f the we ig ht s #
 # a n d b iase s.Stor e the  results in t hegrad s  di ction ary.Forex ample ,      #
 #  grads['W1'] sh ould  store th e g ra die nt  on W 1 , andbea m atrix o f sames ize  # ## ################## ## # # ## ######## ###### # ## ## # ######## ## ### #### # # ##### #### # ## 
  # com pute t h egr adienton  score s  d sco res = prob s
  ds cores[ra nge(N ) ,y] -= 1
  dsc o res /= N

  # W2 a nd b2
 gr ads['W2'] =  np. d ot(h idde n _l aye r .T, d score s)  g rads['b2'] = np.sum (d scores , axi s=0)
  # next  backpropi n t o hidden  lay e r dhidden = np. dot(d scores, W2 . T)
  # b ackpr op the R eLU non-l i n earity
 dh idd en[ hid d e n_ layer <= 0] = 0 
  #  f inallyint o W,b
 gr ads ['W 1']  =  np.dot(X .T, dhid de n) 
 g rad s['b1 ' ] = np.s um (dh id den , axi s =0)

 # ad d re gu la r iza tion gr a di e n t co nt ri buti on grads ['W2 ' ] + = reg *  W2
  gra ds[ ' W1']  + =reg * W 1
  ######### ## ########## ## ### ###### # # ######## ####################### # ####### ### #
  #                         EN D OF Y OUR C OD E                  # 
 ##### ## #### ####### ################## # ### ############# ### #### # # ## ### # ## # ### ## # 

r eturn loss, gra ds

 /*
Co py r ig ht 2019 Th e  Je ts tack ce rt-mana ger c o ntribut ors.

Lic ensed und er  the A pac he License , Versio n 2.0 (th e  "Lic e ns e");you  may n ot  us e thi s file exc ept i n comp li ance w ith t he  License .
You may obtain a copy  of th e Lic ens e at

   ht t p:/ /www.apac he.o rg/license s/L ICE NSE-2 .0Unles s re q ui red by ap plic a ble law o r  a gre e d  t o in writin g , sof tware 
di s tribut ed u nder the Licensei s distributedon a n "AS  IS "  BAS IS 
probs)/N
 _reg_loss =_0.5*reg*np.sum(W1*W1) + 0.5*reg*np.sum(W2*W2)
 _loss =_data_loss_+ reg_loss
__#############################################################################
  #_  _   _  __             __ __END_OF YOUR CODE  _    _ _       __  _       #
 _#############################################################################

  # compute the gradients
_ grads =_{}
__#############################################################################
  # TODO:_Compute the backward pass, computing the_derivatives of the weights #
 _# and biases. Store the results in_the grads dictionary. For example, _    _#
 _# grads['W1'] should store the_gradient on W1,_and be_a matrix of_same size #
  #############################################################################
 _# compute the_gradient on scores
  dscores =_probs
_ dscores[range(N),y] -=_1
__dscores /=_N

  #_W2_and b2
__grads['W2'] = np.dot(hidden_layer.T, dscores)
  grads['b2']_=_np.sum(dscores, axis=0)
  # next backprop into_hidden layer
  dhidden_=_np.dot(dscores, W2.T)
  #_backprop the ReLU non-linearity
 _dhidden[hidden_layer <= 0] = 0
 _# finally_into W,b
_ grads['W1'] = np.dot(X.T, dhidden)
  grads['b1'] = np.sum(dhidden, axis=0)

 _# add regularization gradient contribution
 _grads['W2'] += reg *_W2
 _grads['W1']_+= reg *_W1
_ #############################################################################
_ #     _ _     _   __     _     END_OF YOUR CODE  ___    _     _  _      __  #
  #############################################################################

 _return_loss, grads

 /*
Copyright 2019 The Jetstack_cert-manager_contributors.

Licensed_under the Apache License, Version_2.0 (the "License");
you may not use_this file except in compliance with the License.
You may_obtain a copy_of the License at

 ___http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,_software
distributed under_the License is_distributed on an "AS IS" BASIS