(eph, epdlogp)
return {'W1':dW1, 'W2':dW2}
backward pass. (eph is array of intermediate hidden states)
backward pass. (eph is array of intermediate hidden states)
backward pass . ( eph is array of intermediate hidden states )
def policy_backward(eph, epdlogp):
  """ backward pass. (eph is array of intermediate hidden states) """
  dW2 = np.dot(eph.T, epdlogp).ravel()
  dh = np.outer(epdlogp, model['W2'])
  dh[eph <= 0] = 0 # backpro prelu
  dW1 = np.dot(dh.T, epx)
  return {'W1':dW1, 'W2':dW2}
def policy_backward ( eph , epdlogp ) : dW2 = np . dot ( eph . T , epdlogp ) . ravel ( ) dh = np . outer ( epdlogp , model [ 'W2' ] ) dh [ eph <= 0 ] = 0 # backpro prelu dW1 = np . dot ( dh . T , epx ) return { 'W1' : dW1 , 'W2' : dW2 }