code: def channelwise_locally_connected2d(input, W, flip_filters=True):
      """
      channelwise 2D convolution with unshared weights, no stride,
      'same' padding, no dilation and no bias
      """
      num_batch, input_channels, input_rows, input_cols = input.shape
      (
          num_filters,
          filter_rows,
          filter_cols,
          output_rows,
          output_cols,
      ) = W.shape
      assert input_channels == num_filters
      assert filter_rows % 2 == 1
      assert filter_cols % 2 == 1
      output = np.zeros(
          (num_batch, num_filters, output_rows, output_cols)
      )
      for b in range(num_batch):
          for f in range(num_filters):
              for i_out in range(output_rows):
                  for j_out in range(output_cols):
                      for i_filter in range(filter_rows):
                          i_in = i_out + i_filter - (filter_rows // 2)
                          if not (0 <= i_in < input_rows):
                              continue
                          for j_filter in range(filter_cols):
                              j_in = (
                                  j_out + j_filter - (filter_cols // 2)
                              )
                              if not (0 <= j_in < input_cols):
                                  continue
                              if flip_filters:
                                  inc = (
                                      input[b, f, i_in, j_in]
                                      * W[
                                          f,
                                          -i_filter - 1,
                                          -j_filter - 1,
                                          i_out,
                                          j_out,
                                      ]
                                  )
                              else:
                                  inc = (
                                      input[b, f, i_in, j_in]
                                      * W[
                                          f,
                                          i_filter,
                                          j_filter,
                                          i_out,
                                          j_out,
                                      ]
                                  )
                              output[b, f, i_out, j_out] += inc
      return output
  
file_path: Lasagne/lasagne/tests/layers/test_local.py
imports: import numpy
  import pytest
  import theano
  from lasagne.utils import floatX
label_desc: Use image node_id 2 for calling a global function with example usage: channelwise_locally_connected2d(input, W, flip_filters) and returns: output