Convolution Neural Network Using Tensorflow

Convolution Neural Network is a widely used Deep Learning algorithm. The main purpose of using CNN is to scale down the input shape. In the example below we take 4 dimension image pixels with a total number of 50 images data of 64 pixels. Since we know that an image is made of three colors i.e. RGB, thus the 4 value 3 denotes a color image. 

On passing the input image pixel to Conv2D it scales down the input size. 

Example:

Python3




import tensorflow as tf
import tensorflow.keras as keras
 
image_pixel = (50,64,64,3)
cnn_feature = tf.random.normal(image_pixel)
cnn_label = keras.layers.Conv2D(2, 3, activation='relu',
                                input_shape=image_pixel[1:])(
  cnn_feature)
print(cnn_label.shape)


Output: 

(50, 62, 62, 2)

By providing padding argument as same the input size shall remain the same.

Python3




image_pixel = (50, 64, 64, 3)
cnn_feature = tf.random.normal(image_pixel)
cnn_label = keras.layers.Conv2D(
    2, 3, activation='relu',
  padding="same",
  input_shape=image_pixel[1:])(cnn_feature)
print(cnn_label.shape)


Output:

(50, 64, 64, 2)

The pixel-sized is unchanged as we have provided padding to be the same. 

Python Tensorflow – tf.keras.layers.Conv2D() Function

In this article, we shall look at the in-depth use of tf.keras.layers.Conv2D() in a python programming language.

Similar Reads

Convolution Neural Network: CNN

Computer Vision is changing the world by training machines with large data to imitate human vision. A Convolutional Neural Network (CNN) is a specific type of artificial neural network that uses perceptrons/computer graphs, a machine learning unit algorithm used to analyze data. This data mainly involves images. A 3D  vector dimension is passed through feature maps and then this is downsampled using the Pooling technique. The widely used Pooling technique to downsample the image feature maps is MaxPooling and MeanPooling....

Application Of CNN:

Convolution Neural Network is widely used in Computer Vision Technology, the main application includes:...

CNN Implementation In Keras: tk.keras.layers.Conv2D()

Class Structure Of Conv2D:...

Convolution Neural Network Using Tensorflow:

Convolution Neural Network is a widely used Deep Learning algorithm. The main purpose of using CNN is to scale down the input shape. In the example below we take 4 dimension image pixels with a total number of 50 images data of 64 pixels. Since we know that an image is made of three colors i.e. RGB, thus the 4 value 3 denotes a color image....

Implementing keras.layers.Conv2D() Model:

...