title: how to make a custom padding using Keras to MNIST data set images
body: <p>1- downloaded the MNIST
  2- Built the model....
  How padding is added to the upper side and left side of each image(one row and one column)? is it before or within the convolution layer? from what I understood there is &quot;valid&quot; and &quot;same&quot; padding in Keras which does not give much flexibility! A little help is much appreciated... thanks in advance.</p>
  <pre><code>import tensorflow as tf
  from tensorflow.keras.datasets import mnist
  from keras.utils.generic_utils import get_custom_objects
  from tensorflow.keras.models import Sequential
  from tensorflow.keras.layers import Dense, Dropout, Flatten, Activation
  from tensorflow.keras.layers import Conv2D
  import numpy as np
  import matplotlib.pyplot as plt
  
  # Custom activation function
  def custom_activation(x):
      return (x**2) 
  
  # Before creating the model, I update Keras' custom objects:
  get_custom_objects().update({'custom_activation': Activation(custom_activation)})
  
  
  # Model configuration / Parameters
  img_width, img_height = 28, 28
  batch_size = 200
  no_epochs = 50
  no_classes = 10
  verbosity = 1
  
  # Load MNIST dataset
  (input_train, target_train), (input_test, target_test) = mnist.load_data()
  
  # Reshape data
  input_train = input_train.reshape(input_train.shape[0], img_width, img_height, 1)
  input_test = input_test.reshape(input_test.shape[0], img_width, img_height, 1)
  input_shape = (img_width, img_height, 1)
      
  # Parse numbers as floats
  input_train = input_train.astype('float32')
  input_test = input_test.astype('float32')
  
  # Normalize data: [0, 1].
  input_train = input_train / 255
  input_test = input_test / 255
  
  # Convert target vectors to categorical targets
  target_train = tf.keras.utils.to_categorical(target_train, no_classes)
  target_test = tf.keras.utils.to_categorical(target_test, no_classes)
  
  #build the model
  model = Sequential()
  
  # 1) Convolutional Layer
  model.add(Conv2D(5, kernel_size=(5, 5), strides = (2, 2), activation=custom_activation, input_shape=((input_shape))))
  
  # 2) Flatten Layer
  model.add(Flatten())
  
  # 3) Square Activation Layer
  model.add(Dense(100, activation=custom_activation))
  model.add(Dropout(0.2, input_shape=(100,)))
  
  # 4) Square Activation Layer
  model.add(Dense(10, activation=custom_activation))
  
  # 5) Sigmoid / Softmax Activation Function
  model.add(Dense(no_classes, activation='sigmoid'))
  </code></pre>