def ConvOuter(edge, grad):
  """Get the gradient for the weights in this edge.
  Args:
    grad: (output) the gradient for the weights in this edge.
  """
  w = edge.params['weight']
  conv = edge.conv_params
  size = conv.size
  stride = conv.stride
  padding = conv.padding
  num_filters = conv.num_filters
  num_colors = conv.num_colors

  f, numdims = w.shape
  assert f == num_filters, 'f is %d but num_filters is %d' % (f, num_filters)
  if edge.conv:
    assert numdims == size**2 * num_colors
  input_t = edge.input_t
  if conv.max_pool:
    output_t = edge.unpooled_layer
  elif conv.rnorm:
    output_t = edge.rnorm_temp2
  else:
    output_t = edge.output_t2
  numdims, numimages = edge.node1.state.shape

  assert numdims % num_colors == 0
  x = int(math.sqrt(numdims / num_colors))

  assert x**2 == numdims/num_colors

  n_locs = (x + 2 * padding - size) / stride + 1

  if edge.conv:
    cc.convOutp(input_t, output_t, grad, n_locs, padding, size, stride, num_colors)
  else:
    cc.localOutp(input_t, output_t, grad, n_locs, padding, size, stride, num_colors)
Get the gradient for the weights in this edge.
  Args:
    grad: (output) the gradient for the weights in this edge.
  
deepnet/convolutions.py