(style_end_points, stylized_end_points, style_weights)
return total_style_loss, style_loss_dict
Style loss.

  Args:
    style_end_points: dict mapping VGG16 layer names to their corresponding
        Tensor value for the style input.
    stylized_end_points: dict mapping VGG16 layer names to their corresponding
        Tensor value for the stylized input.
    style_weights: dict mapping layer names to their associated style loss
        weight. Keys that are missing from the dict won't have their style
        loss computed.

  Returns:
    Tensor for the total style loss, dict mapping loss names to losses.
Style loss.
Style loss .
def style_loss(style_end_points, stylized_end_points, style_weights):
  """Style loss.

  Args:
    style_end_points: dict mapping VGG16 layer names to their corresponding
        Tensor value for the style input.
    stylized_end_points: dict mapping VGG16 layer names to their corresponding
        Tensor value for the stylized input.
    style_weights: dict mapping layer names to their associated style loss
        weight. Keys that are missing from the dict won't have their style
        loss computed.

  Returns:
    Tensor for the total style loss, dict mapping loss names to losses.
  """
  total_style_loss = np.float32(0.0)
  style_loss_dict = {}

  for name, weight in style_weights.items():
    loss = tf.reduce_mean(
        (learning_utils.gram_matrix(stylized_end_points[name]) -
         learning_utils.gram_matrix(style_end_points[name])) ** 2)
    weighted_loss = weight * loss

    style_loss_dict['style_loss/' + name] = loss
    style_loss_dict['weighted_style_loss/' + name] = weighted_loss
    total_style_loss += weighted_loss

  style_loss_dict['total_style_loss'] = total_style_loss

  return total_style_loss, style_loss_dict
def style_loss ( style_end_points , stylized_end_points , style_weights ) : total_style_loss = np . float32 ( 0.0 ) style_loss_dict = { } for name , weight in style_weights . items ( ) : loss = tf . reduce_mean ( ( learning_utils . gram_matrix ( stylized_end_points [ name ] ) - learning_utils . gram_matrix ( style_end_points [ name ] ) ) ** 2 ) weighted_loss = weight * loss style_loss_dict [ 'style_loss/' + name ] = loss style_loss_dict [ 'weighted_style_loss/' + name ] = weighted_loss total_style_loss += weighted_loss style_loss_dict [ 'total_style_loss' ] = total_style_loss return total_style_loss , style_loss_dict