code: def test_output_with_random_filter(
      self, filters, in_channels, strides
  ):
      # Build a cnn with random filter weights
      with tf.compat.v1.variable_scope("CNN"):
          self.cnn2 = cnn(
              input_var=self._input_ph,
              input_dim=self.input_dim,
              filters=filters,
              strides=strides,
              name="cnn1",
              padding="VALID",
              hidden_nonlinearity=self.hidden_nonlinearity,
          )
  
      self.sess.run(tf.compat.v1.global_variables_initializer())
  
      result = self.sess.run(
          self.cnn2, feed_dict={self._input_ph: self.obs_input}
      )
  
      two_layer = len(filters) == 2
      # get weight values
      with tf.compat.v1.variable_scope("CNN", reuse=True):
          h0_w = tf.compat.v1.get_variable("cnn1/h0/weight").eval()
          h0_b = tf.compat.v1.get_variable("cnn1/h0/bias").eval()
          if two_layer:
              h1_w = tf.compat.v1.get_variable("cnn1/h1/weight").eval()
              h1_b = tf.compat.v1.get_variable("cnn1/h1/bias").eval()
      filter_weights = (h0_w, h1_w) if two_layer else (h0_w,)
      filter_bias = (h0_b, h1_b) if two_layer else (h0_b,)
  
      # convolution according to TensorFlow's approach
      input_val = convolve(
          _input=self.obs_input,
          filter_weights=filter_weights,
          filter_bias=filter_bias,
          strides=strides,
          filters=filters,
          in_channels=in_channels,
          hidden_nonlinearity=self.hidden_nonlinearity,
      )
  
      # flatten
      dense_out = input_val.reshape((self.batch_size, -1)).astype(
          np.float32
      )
      np.testing.assert_array_almost_equal(dense_out, result)
  
file_path: garage/tests/garage/tf/models/test_cnn.py
imports: import numpy
  import pytest
  import tensorflow
  from garage.tf.models.cnn import cnn, cnn_with_max_pooling
  from tests.fixtures import TfGraphTestCase
  from tests.helpers import convolve, max_pooling
label_desc: Use image node_id 6 for calling the TestCNN obj's underlying member method code with example usage: obj.test_output_with_random_filter(filters, in_channels, strides) without return types