'Adds a 2D convolutional layer.'

def add_conv2d(self, num_units, mapsize=1, stride=1, stddev_factor=1.0):

    assert ((len(self.get_output().get_shape()) == 4) and 'Previous    layer    must    be    4-dimensional    (batch,    width,    height,    channels)')
    with tf.variable_scope(self._get_layer_str()):
        prev_units = self._get_num_inputs()
        initw = self._glorot_initializer_conv2d(prev_units, num_units, mapsize, stddev_factor=stddev_factor)
        weight = tf.get_variable('weight', initializer=initw)
        out = tf.nn.conv2d(self.get_output(), weight, strides=[1, stride, stride, 1], padding='SAME')
        initb = tf.constant(0.0, shape=[num_units])
        bias = tf.get_variable('bias', initializer=initb)
        out = tf.nn.bias_add(out, bias)
    self.outputs.append(out)
    return self
