Why convolutional layer learns only biases?

I`m training a siamese CNN to distinguish between pairs of images and though my train/val binary cross-entropy loss values show negative trend, implying some of the model parameters are being updated, I noticed that convolution kernels barely change while their biases change significantly tensorboard weights histogram image. Also, while loss value decreases, accuracy appears to be frozen for some epochs and then instantly shoots up accuracy and loss plots.

Q1: If this is caused by vanishing gradient, why would it appear in such a small model and why biases are still updated well? How do I fix this?

Q2: Why is accuracy behaving in such a way?

My model architecture is as follows:

def get_embedder(size):
    embedder = models.Sequential()
    embedder.add(layers.Input([size, size, 3]))
    embedder.add(layers.Conv2D(64, 3, padding='same', activation='elu'))
    embedder.add(layers.Conv2D(64, 3, padding='same', activation='elu'))
    embedder.add(layers.MaxPool2D())
    embedder.add(layers.Conv2D(128, 3, padding='same', activation='elu'))
    embedder.add(layers.Conv2D(128, 3, padding='same', activation='elu'))
    embedder.add(layers.MaxPool2D())
    embedder.add(layers.Conv2D(256, 3, padding='same', activation='elu'))
    embedder.add(layers.MaxPool2D())
    embedder.add(layers.Conv2D(512, 3, padding='same', activation='elu'))
    embedder.add(layers.MaxPool2D())
    embedder.add(layers.Conv2D(1024, 3, padding='same', activation='elu'))
    embedder.add(layers.GlobalMaxPooling2D())
    return embedder

base = get_embedder(size)
embedder = models.Model(inputs=base.input, outputs=base.output)
left_input = layers.Input(input_shape)
right_input = layers.Input(input_shape)

left = embedder(left_input)
right = embedder(right_input)

x = layers.Lambda(lambda t: tf.norm(t[0] - t[1], axis=-1, keepdims=True, ord=1))([left, right])
out = layers.Dense(1, activation='sigmoid')(x)
model = models.Model(inputs=[left_input, right_input], outputs=out)

Topic siamese-networks convolutional-neural-network tensorflow deep-learning

Category Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.