Batch Normalization: Apply mean subtraction and variance scaling
        :param x: input feature map stack
        :param type: string, either 'conv' or 'fc'
        :param epsilon: float
        :return: output feature map stack

def batch_norm(self, x, type='conv', epsilon=1e-3):
        """
        Batch Normalization: Apply mean subtraction and variance scaling
        :param x: input feature map stack
        :param type: string, either 'conv' or 'fc'
        :param epsilon: float
        :return: output feature map stack
        """
        # Determine indices over which to calculate moments, based on layer type
        if type == 'conv':
            size = [0, 1, 2]
        else:  # type == 'fc'
            size = [0]

        # Calculate batch mean and variance
        batch_mean1, batch_var1 = tf.nn.moments(x, size, keep_dims=True)

        # Apply the initial batch normalizing transform
        z1_hat = (x - batch_mean1) / tf.sqrt(batch_var1 + epsilon)
        return z1_hat