(style_input_,
                     activation_names,
                     activation_depths,
                     is_training=True,
                     trainable=True,
                     inception_end_point='Mixed_6e',
                     style_prediction_bottleneck=100,
                     reuse=None)
return style_params, bottleneck_feat
Maps style images to the style embeddings (beta and gamma parameters).

  Args:
    style_input_: Tensor. Batch of style input images.
    activation_names: string. Scope names of the activations of the transformer
        network which are used to apply style normalization.
    activation_depths: Shapes of the activations of the transformer network
        which are used to apply style normalization.
    is_training: bool. Is it training phase or not?
    trainable: bool. Should the parameters be marked as trainable?
    inception_end_point: string. Specifies the endpoint to construct the
        inception_v3 network up to. This network is part of the style prediction
        network.
    style_prediction_bottleneck: int. Specifies the bottleneck size in the
        number of parameters of the style embedding.
    reuse: bool. Whether to reuse model parameters. Defaults to False.

  Returns:
    Tensor for the output of the style prediction network, Tensor for the
        bottleneck of style parameters of the style prediction network.
Maps style images to the style embeddings (beta and gamma parameters).
Maps style images to the style embeddings ( beta and gamma parameters ) .
def style_prediction(style_input_,
                     activation_names,
                     activation_depths,
                     is_training=True,
                     trainable=True,
                     inception_end_point='Mixed_6e',
                     style_prediction_bottleneck=100,
                     reuse=None):
  """Maps style images to the style embeddings (beta and gamma parameters).

  Args:
    style_input_: Tensor. Batch of style input images.
    activation_names: string. Scope names of the activations of the transformer
        network which are used to apply style normalization.
    activation_depths: Shapes of the activations of the transformer network
        which are used to apply style normalization.
    is_training: bool. Is it training phase or not?
    trainable: bool. Should the parameters be marked as trainable?
    inception_end_point: string. Specifies the endpoint to construct the
        inception_v3 network up to. This network is part of the style prediction
        network.
    style_prediction_bottleneck: int. Specifies the bottleneck size in the
        number of parameters of the style embedding.
    reuse: bool. Whether to reuse model parameters. Defaults to False.

  Returns:
    Tensor for the output of the style prediction network, Tensor for the
        bottleneck of style parameters of the style prediction network.
  """
  with tf.name_scope('style_prediction') and tf.variable_scope(
      tf.get_variable_scope(), reuse=reuse):
    with slim.arg_scope(_inception_v3_arg_scope(is_training=is_training)):
      with slim.arg_scope(
          [slim.conv2d, slim.fully_connected, slim.batch_norm],
          trainable=trainable):
        with slim.arg_scope(
            [slim.batch_norm, slim.dropout], is_training=is_training):
          _, end_points = inception_v3.inception_v3_base(
              style_input_,
              scope='InceptionV3',
              final_endpoint=inception_end_point)

    # Shape of feat_convlayer is (batch_size, ?, ?, depth).
    # For Mixed_6e end point, depth is 768, for input image size of 256x265
    # width and height are 14x14.
    feat_convlayer = end_points[inception_end_point]
    with tf.name_scope('bottleneck'):
      # (batch_size, 1, 1, depth).
      bottleneck_feat = tf.reduce_mean(
          feat_convlayer, axis=[1, 2], keep_dims=True)

    if style_prediction_bottleneck > 0:
      with slim.arg_scope(
          [slim.conv2d],
          activation_fn=None,
          normalizer_fn=None,
          trainable=trainable):
        # (batch_size, 1, 1, style_prediction_bottleneck).
        bottleneck_feat = slim.conv2d(bottleneck_feat,
                                      style_prediction_bottleneck, [1, 1])

    style_params = {}
    with tf.variable_scope('style_params'):
      for i in range(len(activation_depths)):
        with tf.variable_scope(activation_names[i], reuse=reuse):
          with slim.arg_scope(
              [slim.conv2d],
              activation_fn=None,
              normalizer_fn=None,
              trainable=trainable):

            # Computing beta parameter of the style normalization for the
            # activation_names[i] layer of the style transformer network.
            # (batch_size, 1, 1, activation_depths[i])
            beta = slim.conv2d(bottleneck_feat, activation_depths[i], [1, 1])
            # (batch_size, activation_depths[i])
            beta = tf.squeeze(beta, [1, 2], name='SpatialSqueeze')
            style_params['{}/beta'.format(activation_names[i])] = beta

            # Computing gamma parameter of the style normalization for the
            # activation_names[i] layer of the style transformer network.
            # (batch_size, 1, 1, activation_depths[i])
            gamma = slim.conv2d(bottleneck_feat, activation_depths[i], [1, 1])
            # (batch_size, activation_depths[i])
            gamma = tf.squeeze(gamma, [1, 2], name='SpatialSqueeze')
            style_params['{}/gamma'.format(activation_names[i])] = gamma

  return style_params, bottleneck_feat
def style_prediction ( style_input_ , activation_names , activation_depths , is_training = True , trainable = True , inception_end_point = 'Mixed_6e' , style_prediction_bottleneck = 100 , reuse = None ) : with tf . name_scope ( 'style_prediction' ) and tf . variable_scope ( tf . get_variable_scope ( ) , reuse = reuse ) : with slim . arg_scope ( _inception_v3_arg_scope ( is_training = is_training ) ) : with slim . arg_scope ( [ slim . conv2d , slim . fully_connected , slim . batch_norm ] , trainable = trainable ) : with slim . arg_scope ( [ slim . batch_norm , slim . dropout ] , is_training = is_training ) : _ , end_points = inception_v3 . inception_v3_base ( style_input_ , scope = 'InceptionV3' , final_endpoint = inception_end_point ) # Shape of feat_convlayer is (batch_size, ?, ?, depth). # For Mixed_6e end point, depth is 768, for input image size of 256x265 # width and height are 14x14. feat_convlayer = end_points [ inception_end_point ] with tf . name_scope ( 'bottleneck' ) : # (batch_size, 1, 1, depth). bottleneck_feat = tf . reduce_mean ( feat_convlayer , axis = [ 1 , 2 ] , keep_dims = True ) if style_prediction_bottleneck > 0 : with slim . arg_scope ( [ slim . conv2d ] , activation_fn = None , normalizer_fn = None , trainable = trainable ) : # (batch_size, 1, 1, style_prediction_bottleneck). bottleneck_feat = slim . conv2d ( bottleneck_feat , style_prediction_bottleneck , [ 1 , 1 ] ) style_params = { } with tf . variable_scope ( 'style_params' ) : for i in range ( len ( activation_depths ) ) : with tf . variable_scope ( activation_names [ i ] , reuse = reuse ) : with slim . arg_scope ( [ slim . conv2d ] , activation_fn = None , normalizer_fn = None , trainable = trainable ) : # Computing beta parameter of the style normalization for the # activation_names[i] layer of the style transformer network. # (batch_size, 1, 1, activation_depths[i]) beta = slim . conv2d ( bottleneck_feat , activation_depths [ i ] , [ 1 , 1 ] ) # (batch_size, activation_depths[i]) beta = tf . squeeze ( beta , [ 1 , 2 ] , name = 'SpatialSqueeze' ) style_params [ '{}/beta' . format ( activation_names [ i ] ) ] = beta # Computing gamma parameter of the style normalization for the # activation_names[i] layer of the style transformer network. # (batch_size, 1, 1, activation_depths[i]) gamma = slim . conv2d ( bottleneck_feat , activation_depths [ i ] , [ 1 , 1 ] ) # (batch_size, activation_depths[i]) gamma = tf . squeeze ( gamma , [ 1 , 2 ] , name = 'SpatialSqueeze' ) style_params [ '{}/gamma' . format ( activation_names [ i ] ) ] = gamma return style_params , bottleneck_feat