def transplant(new_net, net, suffix=''):
 for p in net.params:
  p_new = (p + suffix)
  if (p_new not in new_net.params):
   print 'dropping', p
   continue
  for i in range(len(net.params[p])):
   if (i > (len(new_net.params[p_new]) - 1)):
    print 'dropping', p, i
    break
   if (net.params[p][i].data.shape != new_net.params[p_new][i].data.shape):
    print 'coercing', p, i, 'from', net.params[p][i].data.shape, 'to', new_net.params[p_new][i].data.shape
   else:
    print 'copying', p, ' -> ', p_new, i
   new_net.params[p_new][i].data.flat = net.params[p][i].data.flat

def transplant ( new_net , net , suffix = '' ) : for p in net . params : p_new = ( p + suffix ) if ( p_new not in new_net . params ) : print 'dropping' , p continue for i in range ( len ( net . params [ p ] ) ) : if ( i > ( len ( new_net . params [ p_new ] ) - 1 ) ) : print 'dropping' , p , i break if ( net . params [ p ] [ i ] . data . shape != new_net . params [ p_new ] [ i ] . data . shape ) : print 'coercing' , p , i , 'from' , net . params [ p ] [ i ] . data . shape , 'to' , new_net . params [ p_new ] [ i ] . data . shape else : print 'copying' , p , ' -> ' , p_new , i new_net . params [ p_new ] [ i ] . data . flat = net . params [ p ] [ i ] . data . flat
transfer weights by copying matching parameters .