class_docstr: NeuralNetwork is a class that interfaces the verification code with
  the neural net parameters (weights).
class_docstr_tok: ["NeuralNetwork","is","a","class","that","interfaces","the","verification","code","with","the","neural","net","parameters","(","weights",")","."]
docstr: Performs forward pass through the layer weights at layer_index.
  
  Args:
    vector: vector that has to be passed through in forward pass
    layer_index: index of the layer
    is_transpose: whether the weights of the layer have to be transposed
    is_abs: whether to take the absolute value of the weights
  
  Returns:
    tensor that corresponds to the forward pass through the layer
  Raises:
    ValueError: if the layer_index is negative or more than num hidden layers
docstr_tok: ["Performs","forward","pass","through","the","layer","weights","at","layer_index",".","Args",":","vector",":","vector","that","has","to","be","passed","through","in","forward","pass","layer_index",":","index","of","the","layer","is_transpose",":","whether","the","weights","of","the","layer","have","to","be","transposed","is_abs",":","whether","to","take","the","absolute","value","of","the","weights","Returns",":","tensor","that","corresponds","to","the","forward","pass","through","the","layer","Raises",":","ValueError",":","if","the","layer_index","is","negative","or","more","than","num","hidden","layers"]
code: def forward_pass(
      self, vector, layer_index, is_transpose=False, is_abs=False
  ):
      """Performs forward pass through the layer weights at layer_index.
  
      Args:
        vector: vector that has to be passed through in forward pass
        layer_index: index of the layer
        is_transpose: whether the weights of the layer have to be transposed
        is_abs: whether to take the absolute value of the weights
  
      Returns:
        tensor that corresponds to the forward pass through the layer
      Raises:
        ValueError: if the layer_index is negative or more than num hidden layers
      """
      if layer_index < 0 or layer_index > self.num_hidden_layers:
          raise ValueError("Invalid layer index")
  
      layer_type = self.layer_types[layer_index]
      weight = self.weights[layer_index]
      if is_abs:
          weight = tf.abs(weight)
      if is_transpose:
          vector = tf.reshape(vector, self.output_shapes[layer_index])
      else:
          vector = tf.reshape(vector, self.input_shapes[layer_index])
  
      if layer_type in {"ff", "ff_relu"}:
          if is_transpose:
              weight = tf.transpose(weight)
          return_vector = tf.matmul(weight, vector)
      elif layer_type in {"conv", "conv_relu"}:
          if is_transpose:
              return_vector = tf.nn.conv2d_transpose(
                  vector,
                  weight,
                  output_shape=self.input_shapes[layer_index],
                  strides=[
                      1,
                      self.cnn_params[layer_index]["stride"],
                      self.cnn_params[layer_index]["stride"],
                      1,
                  ],
                  padding=self.cnn_params[layer_index]["padding"],
              )
          else:
              return_vector = tf.nn.conv2d(
                  vector,
                  weight,
                  strides=[
                      1,
                      self.cnn_params[layer_index]["stride"],
                      self.cnn_params[layer_index]["stride"],
                      1,
                  ],
                  padding=self.cnn_params[layer_index]["padding"],
              )
      else:
          raise NotImplementedError(
              "Unsupported layer type: {0}".format(layer_type)
          )
      if is_transpose:
          return tf.reshape(return_vector, (self.sizes[layer_index], 1))
      return tf.reshape(return_vector, (self.sizes[layer_index + 1], 1))
  
file_path: cleverhans/cleverhans/experimental/certification/nn.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import json
  import numpy
  import tensorflow
label_desc: Use image node_id 2 for calling the NeuralNetwork obj's underlying member method code with example usage: obj.forward_pass(vector, layer_index, is_transpose, is_abs) and returns: tf, tf