def style_loss(style_image, target_image, style_masks, target_masks):
 assert (3 == K.ndim(style_image) == K.ndim(target_image))
 assert (3 == K.ndim(style_masks) == K.ndim(target_masks))
 loss = K.variable(0)
 for i in xrange(nb_labels):
  if (K.image_dim_ordering() == 'th'):
   style_mask = style_masks[i, :, :]
   target_mask = target_masks[i, :, :]
  else:
   style_mask = style_masks[:, :, i]
   target_mask = target_masks[:, :, i]
  loss += region_style_loss(style_image, target_image, style_mask, target_mask)
 return loss

def style_loss ( style_image , target_image , style_masks , target_masks ) : assert ( 3 == K . ndim ( style_image ) == K . ndim ( target_image ) ) assert ( 3 == K . ndim ( style_masks ) == K . ndim ( target_masks ) ) loss = K . variable ( 0 ) for i in xrange ( nb_labels ) : if ( K . image_dim_ordering ( ) == 'th' ) : style_mask = style_masks [ i , : , : ] target_mask = target_masks [ i , : , : ] else : style_mask = style_masks [ : , : , i ] target_mask = target_masks [ : , : , i ] loss += region_style_loss ( style_image , target_image , style_mask , target_mask ) return loss
calculate style loss between style_image and target_image .