def _compute_reprs(net_in, net, layers_style, layers_content, gram_scale=1):
 (repr_s, repr_c) = ({}, {})
 net.blobs['data'].data[0] = net_in
 net.forward()
 for layer in (set(layers_style) | set(layers_content)):
  F = net.blobs[layer].data[0].copy()
  F.shape = (F.shape[0], (-1))
  repr_c[layer] = F
  if (layer in layers_style):
   repr_s[layer] = sgemm(gram_scale, F, F.T)
 return (repr_s, repr_c)

def _compute_reprs ( net_in , net , layers_style , layers_content , gram_scale = 1 ) : ( repr_s , repr_c ) = ( { } , { } ) net . blobs [ 'data' ] . data [ 0 ] = net_in net . forward ( ) for layer in ( set ( layers_style ) | set ( layers_content ) ) : F = net . blobs [ layer ] . data [ 0 ] . copy ( ) F . shape = ( F . shape [ 0 ] , ( - 1 ) ) repr_c [ layer ] = F if ( layer in layers_style ) : repr_s [ layer ] = sgemm ( gram_scale , F , F . T ) return ( repr_s , repr_c )
computes representation matrices for an image .