(style_input_,
                               activation_names,
                               activation_depths,
                               mobilenet_end_point='layer_19',
                               mobilenet_trainable=True,
                               style_params_trainable=False,
                               style_prediction_bottleneck=100,
                               reuse=None)
return style_params, bottleneck_feat
Maps style images to the style embeddings using MobileNetV2.

  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.
    mobilenet_end_point: string. Specifies the endpoint to construct the
        MobileNetV2 network up to. This network is part of the style prediction
        network.
    mobilenet_trainable: bool. Should the MobileNetV2 parameters be marked
        as trainable?
    style_params_trainable: bool. Should the mapping from bottleneck to
        beta and gamma parameters be marked as trainable?
    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 using MobileNetV2.
Maps style images to the style embeddings using MobileNetV2 .
def style_prediction_mobilenet(style_input_,
                               activation_names,
                               activation_depths,
                               mobilenet_end_point='layer_19',
                               mobilenet_trainable=True,
                               style_params_trainable=False,
                               style_prediction_bottleneck=100,
                               reuse=None):
  """Maps style images to the style embeddings using MobileNetV2.

  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.
    mobilenet_end_point: string. Specifies the endpoint to construct the
        MobileNetV2 network up to. This network is part of the style prediction
        network.
    mobilenet_trainable: bool. Should the MobileNetV2 parameters be marked
        as trainable?
    style_params_trainable: bool. Should the mapping from bottleneck to
        beta and gamma parameters be marked as trainable?
    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_mobilenet') and tf.variable_scope(
      tf.get_variable_scope(), reuse=reuse):
    with slim.arg_scope(mobilenet_v2.training_scope(
        is_training=mobilenet_trainable)):
      _, end_points = mobilenet.mobilenet_base(
          style_input_,
          conv_defs=mobilenet_v2.V2_DEF,
          final_endpoint=mobilenet_end_point,
          scope='MobilenetV2'
      )

    feat_convlayer = end_points[mobilenet_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 tf.variable_scope('mobilenet_conv'):
        with slim.arg_scope(
            [slim.conv2d],
            activation_fn=None,
            normalizer_fn=None,
            trainable=mobilenet_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=style_params_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_mobilenet ( style_input_ , activation_names , activation_depths , mobilenet_end_point = 'layer_19' , mobilenet_trainable = True , style_params_trainable = False , style_prediction_bottleneck = 100 , reuse = None ) : with tf . name_scope ( 'style_prediction_mobilenet' ) and tf . variable_scope ( tf . get_variable_scope ( ) , reuse = reuse ) : with slim . arg_scope ( mobilenet_v2 . training_scope ( is_training = mobilenet_trainable ) ) : _ , end_points = mobilenet . mobilenet_base ( style_input_ , conv_defs = mobilenet_v2 . V2_DEF , final_endpoint = mobilenet_end_point , scope = 'MobilenetV2' ) feat_convlayer = end_points [ mobilenet_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 tf . variable_scope ( 'mobilenet_conv' ) : with slim . arg_scope ( [ slim . conv2d ] , activation_fn = None , normalizer_fn = None , trainable = mobilenet_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 = style_params_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