(inputs, stylized_inputs, style_gram_matrices, content_weights,
               style_weights, reuse=False)
return loss, loss_dict
Computes the total loss function.

  The total loss function is composed of a content, a style and a total
  variation term.

  Args:
    inputs: Tensor. The input images.
    stylized_inputs: Tensor. The stylized input images.
    style_gram_matrices: dict mapping layer names to their corresponding
        Gram matrices.
    content_weights: dict mapping layer names to their associated content loss
        weight. Keys that are missing from the dict won't have their content
        loss computed.
    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.
    reuse: bool. Whether to reuse model parameters. Defaults to False.

  Returns:
    Tensor for the total loss, dict mapping loss names to losses.
Computes the total loss function.
Computes the total loss function .
def total_loss(inputs, stylized_inputs, style_gram_matrices, content_weights,
               style_weights, reuse=False):
  """Computes the total loss function.

  The total loss function is composed of a content, a style and a total
  variation term.

  Args:
    inputs: Tensor. The input images.
    stylized_inputs: Tensor. The stylized input images.
    style_gram_matrices: dict mapping layer names to their corresponding
        Gram matrices.
    content_weights: dict mapping layer names to their associated content loss
        weight. Keys that are missing from the dict won't have their content
        loss computed.
    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.
    reuse: bool. Whether to reuse model parameters. Defaults to False.

  Returns:
    Tensor for the total loss, dict mapping loss names to losses.
  """
  # Propagate the input and its stylized version through VGG16.
  end_points = vgg.vgg_16(inputs, reuse=reuse)
  stylized_end_points = vgg.vgg_16(stylized_inputs, reuse=True)

  # Compute the content loss
  total_content_loss, content_loss_dict = content_loss(
      end_points, stylized_end_points, content_weights)

  # Compute the style loss
  total_style_loss, style_loss_dict = style_loss(
      style_gram_matrices, stylized_end_points, style_weights)

  # Compute the total loss
  loss = total_content_loss + total_style_loss

  loss_dict = {'total_loss': loss}
  loss_dict.update(content_loss_dict)
  loss_dict.update(style_loss_dict)

  return loss, loss_dict
def total_loss ( inputs , stylized_inputs , style_gram_matrices , content_weights , style_weights , reuse = False ) : # Propagate the input and its stylized version through VGG16. end_points = vgg . vgg_16 ( inputs , reuse = reuse ) stylized_end_points = vgg . vgg_16 ( stylized_inputs , reuse = True ) # Compute the content loss total_content_loss , content_loss_dict = content_loss ( end_points , stylized_end_points , content_weights ) # Compute the style loss total_style_loss , style_loss_dict = style_loss ( style_gram_matrices , stylized_end_points , style_weights ) # Compute the total loss loss = total_content_loss + total_style_loss loss_dict = { 'total_loss' : loss } loss_dict . update ( content_loss_dict ) loss_dict . update ( style_loss_dict ) return loss , loss_dict