# I want to add some error percentage to the output of max-pooling layer?

## Issue

I want to add some error percentage (relative error) to the output of max-pooling layer in CNN. I am using max pooling layer from keras.
Below is the code

``````i = Input(shape=x_train.shape)
x = Conv2D(32, (3, 3), activation='relu', padding='same')(i)
x = BatchNormalization()(x)
x = Conv2D(32, (3, 3), activation='relu', padding='same')(x)
x = BatchNormalization()(x)
x = MaxPooling2D((2, 2))(x)
``````

How can I add some errors to the output of this layer?
I want to add some fraction of the original output.
e.g. if x is my original output, I want my output to be x+ some fraction of (x).

## Solution

If you just want to add a fraction of the input, you can just use `Add`:

``````x = K.layers.Add()([x, 1/4 * x])
``````

for example:

``````input = K.layers.Input(shape=(5,))
x = K.layers.Add()([input, 1/4 * input])
model = K.Model(inputs=[input], outputs=[x])
model(np.ones((1,5)))
#<tf.Tensor: shape=(1, 5), dtype=float32, numpy=array([[1.25, 1.25, 1.25, 1.25, 1.25]], dtype=float32)>
``````

However this is not noise, and the affine transformation after this layer will vanish what you have done, infact:

``````A(x+ 1/4x)+b
= A(5/4x)+b
= 5/4 * A(x)+b
``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.694044,"math_prob":0.9916582,"size":1430,"snap":"2022-27-2022-33","text_gpt3_token_len":451,"char_repetition_ratio":0.10799439,"word_repetition_ratio":0.03539823,"special_character_ratio":0.33356643,"punctuation_ratio":0.17507419,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9997683,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-09T01:44:22Z\",\"WARC-Record-ID\":\"<urn:uuid:d0c0e898-4ac8-4c77-8ed4-a69414920793>\",\"Content-Length\":\"42550\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:3e4f2719-493e-4c63-9a41-1a2495d228e6>\",\"WARC-Concurrent-To\":\"<urn:uuid:429990a1-2246-463f-b828-e52fdc3b66a6>\",\"WARC-IP-Address\":\"172.67.160.65\",\"WARC-Target-URI\":\"https://errorsfixing.com/i-want-to-add-some-error-percentage-to-the-output-of-max-pooling-layer/\",\"WARC-Payload-Digest\":\"sha1:6HEPYUCXYNOIILTLF5YQGOPBKOMX5SKO\",\"WARC-Block-Digest\":\"sha1:VFAH5NNNG7JYW6UPHV4ARUOGGFSGVPB5\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882570879.37_warc_CC-MAIN-20220809003642-20220809033642-00216.warc.gz\"}"}