class_docstr: Convolutional Neural Network for image classification.
  
  It assumes the inputs are images of shape width x height x channels.
  The precise architecture follows the Tensorflow CNN
  tutorial at https://www.tensorflow.org/tutorials/images/deep_cnn.
  Note that this CNN works both for the agreement and classification models.
  In the agreement case, the provided inputs will be a tuple
  (inputs_src, inputs_target), which are aggregated into one input after the
  convolution layers, right before the fully connected network that makes the
  final prediction.
  
  Attributes:
    output_dim: Integer representing the number of classes.
    channels: Integer representing the number of channels in the input images
      (e.g., 1 for black and white, 3 for RGB).
    aggregation: String representing an aggregation operation, that is applied
      on the two inputs of the agreement model, after they are encoded through
      the convolution layers. See superclass attributes for details.
    activation: An activation function to be applied to the outputs of each
      fully connected layer of the aggregation network.
    is_binary_classification: Boolean specifying if this is model for
      binary classification. If so, it uses a different loss function and
      returns predictions with a single dimension, batch size.
    name: String representing the model name.
class_docstr_tok: ["Convolutional","Neural","Network","for","image","classification",".","It","assumes","the","inputs","are","images","of","shape","width","x","height","x","channels",".","The","precise","architecture","follows","the","Tensorflow","CNN","tutorial","at","https",":","\/\/www.tensorflow.org\/tutorials\/images\/deep_cnn",".","Note","that","this","CNN","works","both","for","the","agreement","and","classification","models",".","In","the","agreement","case",",","the","provided","inputs","will","be","a","tuple","(","inputs_src",",","inputs_target",")",",","which","are","aggregated","into","one","input","after","the","convolution","layers",",","right","before","the","fully","connected","network","that","makes","the","final","prediction",".","Attributes",":","output_dim",":","Integer","representing","the","number","of","classes",".","channels",":","Integer","representing","the","number","of","channels","in","the","input","images","(","e.g.",",","1","for","black","and","white",",","3","for","RGB",")",".","aggregation",":","String","representing","an","aggregation","operation",",","that","is","applied","on","the","two","inputs","of","the","agreement","model",",","after","they","are","encoded","through","the","convolution","layers",".","See","superclass","attributes","for","details",".","activation",":","An","activation","function","to","be","applied","to","the","outputs","of","each","fully","connected","layer","of","the","aggregation","network",".","is_binary_classification",":","Boolean","specifying","if","this","is","model","for","binary","classification",".","If","so",",","it","uses","a","different","loss","function","and","returns","predictions","with","a","single","dimension",",","batch","size",".","name",":","String","representing","the","model","name","."]
docstr: Creates the model prediction op.
  
  For this model, the hidden representation is the last layer
  before the logit computation. The predictions are unnormalized logits.
  
  Args:
    encoding: A tensor containing the model inputs. The first dimension is the
      batch size.
    is_train: A placeholder representing a boolean value that specifies if
      this model will be used for training or for test.
    **kwargs: Other keyword arguments.
  
  Returns:
    predictions: A tensor of logits. For multiclass classification its
      shape is (num_samples, num_classes), where the second dimension contains
      a logit per class. For binary classification, its shape is
      (num_samples,), where each element is the probability of class 1 for
      that sample.
    all_vars: A dictionary mapping from variable name to TensorFlow op
      containing all variables used in this model.
    reg_params: A dictionary mapping from a variable name to a Tensor of
      parameters which will be used for regularization.
docstr_tok: ["Creates","the","model","prediction","op",".","For","this","model",",","the","hidden","representation","is","the","last","layer","before","the","logit","computation",".","The","predictions","are","unnormalized","logits",".","Args",":","encoding",":","A","tensor","containing","the","model","inputs",".","The","first","dimension","is","the","batch","size",".","is_train",":","A","placeholder","representing","a","boolean","value","that","specifies","if","this","model","will","be","used","for","training","or","for","test",".","*","*","kwargs",":","Other","keyword","arguments",".","Returns",":","predictions",":","A","tensor","of","logits",".","For","multiclass","classification","its","shape","is","(","num_samples",",","num_classes",")",",","where","the","second","dimension","contains","a","logit","per","class",".","For","binary","classification",",","its","shape","is","(","num_samples",",",")",",","where","each","element","is","the","probability","of","class","1","for","that","sample",".","all_vars",":","A","dictionary","mapping","from","variable","name","to","TensorFlow","op","containing","all","variables","used","in","this","model",".","reg_params",":","A","dictionary","mapping","from","a","variable","name","to","a","Tensor","of","parameters","which","will","be","used","for","regularization","."]
code: def get_predictions_and_params(self, encoding, is_train, **kwargs):
      """Creates the model prediction op.
  
      For this model, the hidden representation is the last layer
      before the logit computation. The predictions are unnormalized logits.
  
      Args:
        encoding: A tensor containing the model inputs. The first dimension is the
          batch size.
        is_train: A placeholder representing a boolean value that specifies if
          this model will be used for training or for test.
        **kwargs: Other keyword arguments.
  
      Returns:
        predictions: A tensor of logits. For multiclass classification its
          shape is (num_samples, num_classes), where the second dimension contains
          a logit per class. For binary classification, its shape is
          (num_samples,), where each element is the probability of class 1 for
          that sample.
        all_vars: A dictionary mapping from variable name to TensorFlow op
          containing all variables used in this model.
        reg_params: A dictionary mapping from a variable name to a Tensor of
          parameters which will be used for regularization.
      """
      # Build layers.
      with tf.variable_scope(self.name + "/prediction"):
          # We store all variables on which we apply weight decay in a dictionary.
          reg_params = {}
  
          # Create the output layer of the predictions.
          input_size = encoding.get_shape().dims[-1].value
          weights = tf.get_variable(
              "W_outputs",
              shape=(input_size, self.output_dim),
              initializer=tf.truncated_normal_initializer(
                  stddev=1.0 / float(input_size), dtype=tf.float32
              ),
          )
          biases = tf.get_variable(
              "b_outputs",
              initializer=tf.zeros([self.output_dim], dtype=tf.float32),
          )
          predictions = tf.add(
              tf.matmul(encoding, weights), biases, name="predictions"
          )
  
          if self.is_binary_classification:
              predictions = predictions[:, 0]
  
          # Store model variables for easy access.
          variables = tf.get_collection(
              tf.GraphKeys.GLOBAL_VARIABLES,
              scope=tf.get_default_graph().get_name_scope(),
          )
          all_vars = {var.name: var for var in variables}
  
      return predictions, all_vars, reg_params
  
file_path: neural-structured-learning/research/gam/gam/models/cnn.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from .models_base import Model
  import tensorflow
label_desc: Use image node_id 4 for calling the ImageCNNAgreement obj's underlying member method code with example usage: obj.get_predictions_and_params(encoding, is_train) and returns: predictions,  all_vars,  reg_params