<p>Residual Block from <a href="https://arxiv.org/abs/1512.03385" rel="noreferrer">ResNet</a> Architecture is the following :</p>
<p><a href="https://i.stack.imgur.com/r0BS6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/r0BS6.png" alt="Residual Block" /></a></p>
<p>You need to use the <a href="https://www.tensorflow.org/guide/keras/functional" rel="noreferrer">Keras functionnal API</a> because Sequential models are too limited. Its implementation in Keras is :</p>
<pre><code>from tensorflow.keras import layers

def resblock(x, kernelsize, filters):
    fx = layers.Conv2D(filters, kernelsize, activation='relu', padding='same')(x)
    fx = layers.BatchNormalization()(fx)
    fx = layers.Conv2D(filters, kernelsize, padding='same')(fx)
    out = layers.Add()([x,fx])
    out = layers.ReLU()(out)
    out = layers.BatchNormalization()(out)
    return out
</code></pre>
<p><code>BatchNormalisation()</code>layer is not essential but may be a solid option to increase its accuracy. <code>x</code> needs also to have the same number of filters than the <code>filters</code> parameter.</p>
How to code a residual block using two layers of a basic CNN algorithm built with "tensorflow.keras"?
<p>I have a basic CNN model's code built with <strong>tensorflow.keras</strong> library:</p>
<pre><code>model = Sequential()

# First Layer
model.add(Conv2D(64, (3,3), input_shape = (IMG_SIZE,IMG_SIZE,1)))
model.add(Activation(&quot;relu&quot;))
model.add(MaxPooling2D(pool_size = (3,3)))

# Second Layer
model.add(Conv2D(64, (3,3)))
model.add(Activation(&quot;relu&quot;))
model.add(MaxPooling2D(pool_size = (3,3)))

# Third Layer
model.add(Conv2D(64, (3,3)))
model.add(Activation(&quot;relu&quot;))
model.add(MaxPooling2D(pool_size = (3,3)))

# Fourth Layer
model.add(Conv2D(64, (3,3)))
model.add(Activation(&quot;relu&quot;))
model.add(MaxPooling2D(pool_size = (3,3)))

# Fifth Layer
model.add(Conv2D(64, (3,3)))
model.add(Activation(&quot;relu&quot;))
model.add(MaxPooling2D(pool_size = (3,3)))

model.add(Flatten())

# Sixth Layer
model.add(Dense(64))
model.add(Activation(&quot;relu&quot;))

# Seventh Layer
model.add(Dense(1))
model.add(Activation('sigmoid'))
</code></pre>
<p>Now, I want to make a connection between the <strong>second</strong> and the <strong>fourth</strong> layer to achieve a <strong>residual block</strong> using <strong>tensorflow.keras</strong> library.</p>
<p>So, How should I modify the code to achieve such a <strong>residual block</strong>?</p>