def p_norm(x, p=6.0, scale=10.0):
  """
  Compute the p-norm for an image and its gradient.
  
  The p-norm is defined as

  |x|_p = (\sum_i |x_i|^p)^(1/p)

  so strictly speaking this fucntion actually computes the pth power of the
  p-norm.

  We use it as a regularizer to prevent individual pixels from getting too big.
  We don't actually want to drive pixels toward zero; we are more interested in
  making sure they stay within a reasonable range. This suggests that we divide
  the pixels by a scaling factor and use a high value of p; as suggested by
  [1] p=6 tends to work well.

  Inputs:
  - x: numpy array of any shape
  - p: Power for p-norm
  - scale: Scale for p-norm.

  Returns a tuple of:
  - loss: Value of the p-norm 
  """
  loss = (np.abs(x / scale) ** p).sum()
  grad = p / scale * np.sign(x / scale) * np.abs(x / scale) ** (p - 1)
  return loss, grad

  Compute the p-norm for an image and its gradient.
  
  The p-norm is defined as

  |x|_p = (\sum_i |x_i|^p)^(1/p)

  so strictly speaking this fucntion actually computes the pth power of the
  p-norm.

  We use it as a regularizer to prevent individual pixels from getting too big.
  We don't actually want to drive pixels toward zero; we are more interested in
  making sure they stay within a reasonable range. This suggests that we divide
  the pixels by a scaling factor and use a high value of p; as suggested by
  [1] p=6 tends to work well.

  Inputs:
  - x: numpy array of any shape
  - p: Power for p-norm
  - scale: Scale for p-norm.

  Returns a tuple of:
  - loss: Value of the p-norm 
  
cnn_vis.py