def display_wsorted(w, s, r, c, fig, vmax=None, vmin=None, dataset='mnist',
                    title='weights_sorted'):

  if dataset == 'norb':
    numvis = 4096
  else:
    numvis = w.shape[0]
  numhid = w.shape[1]
  sc = s
  sr = numvis/s
  padding = numhid - r*c
  if isinstance(w, np.ndarray):
    w = w.T[:, :sr*sc]
  else:
    w = w.asarray().T[:, :sr*sc]

  vh = w.reshape(sr*numhid, sc)
  pvh = np.zeros((sr, sc, r, c))
  pvh2 = np.zeros((sr*r, sc*c))
  norm_list = []
  for i in range(r):
    for j in range(c):
      pvh[:,:, i, j] = vh[ (i*c+j)*sr : (i*c+j+1)*sr ,:]
      norm = (pvh[:,:,i,j]**2).sum()
      norm_list.append((norm, i, j))
  norm_list.sort(reverse = True)
  index = 0
  for norm, i, j in norm_list:
    ii = c/index
    jj = index%c
    pvh2[ii*sr:(ii+1)*sr , jj*sc:(jj+1)*sc] = pvh[:,:,i,j]
    index+=1
  plt.figure(fig)
  plt.clf()

  plt.suptitle(title)
  # vmax = 0.5
  # vmin = -0.5
  plt.imshow(pvh2, cmap = plt.cm.gray, interpolation = 'nearest', vmax=vmax, vmin=vmin)
  scale = 1
  xmax = sc*c
  ymax = sr*r
  color = 'k'
  for x in range(0,c):
    plt.axvline(x=x*sc/scale,ymin=0,ymax=ymax/scale, color = color)
  for y in range(0,r):
    plt.axhline(y=y*sr/scale, xmin=0,xmax=xmax/scale, color = color)
  plt.draw()

  return pvh
dataset/ETHPy150Open nitishsrivastava/deepnet/deepnet/visualize.py/display_wsorted/swapped operands of `/`