What is atrous Convolution 2D layer in TF learn explain with example

This recipe explains what is atrous Convolution 2D layer in TF learn explain with example

Recipe Objective

This recipe explains how Atrous Convolution 2D layer works in TFLayer.

Atrous Convolution 2D

Its syntax is: tflearn.layers.conv.atrous_conv_2d (incoming, nb_filter, filter_size, rate=1, padding='same', activation='linear', bias=True, weights_init='uniform_scaling', bias_init='zeros', regularizer=None, weight_decay=0.001, trainable=True, restore=True, reuse=False, scope=None, name='AtrousConv2D') It is also known as convolution with holes or dilated convolution.
When the rate parameter is equal to unity, 2D convolution will be performed and when the rate parameter is greater than unity, convolution with holes will be performed. This results in input convolving with inserting rate - 1 zero between two consecutive filters along with width and height.

def atrous_conv_2d(incoming, nb_filter, filter_size, rate=1, padding='same', activation='linear', bias=True, weights_init='uniform_scaling', bias_init='zeros', regularizer=None, weight_decay=0.001, trainable=True, restore=True, reuse=False, scope=None, name="AtrousConv2D"):

    ip = utils.get_incoming_shape(incoming)

    assert len(ip) == 4, "Incoming Tensor shape must be 4-D, not %d-D" % len(input_shape)

    filter_size = utils.autoformat_filter_conv2d(filter_size, ip[-1], nb_filter)

    padding = utils.autoformat_padding(padding)

    with tf.variable_scope(scope, default_name=name, values=[incoming], reuse=reuse) as scope:

       name = scope.name

       if isinstance(weights_init, str):

          weights_init = initializations.get(weights_init)()

       elif type(weights_init) in [tf.Tensor, np.ndarray, list]:

          filter_size = None

       reg = None

       if regularizer is not None:

          reg = lambda y: regularizers.get(regularizer)(y, weight_decay)
       w = vs.variable('w', shape=filter_size, regularizer=W_regul, initializer=weights_init, trainable=trainable, restore=restore)

       tf.add_to_collection(tf.GraphKeys.LAYER_VARIABLES + '/' + name, w)

       a = None

       if bias:

          a_shape = [nb_filter]

       if isinstance(bias_init, str):

          bias_init = initializations.get(bias_init)()

       elif type(bias_init) in [tf.Tensor, np.ndarray, list]:

          a_shape = None

       a = vs.variable('a', shape=a_shape, initializer=bias_init, trainable=trainable, restore=restore)

       tf.add_to_collection(tf.GraphKeys.LAYER_VARIABLES + '/' + name, a)

       inf = tf.nn.atrous_conv2d(incoming, w, rate, padding)

       if a is not None: inf = tf.nn.bias_add(inf, a)

          if activation:

             if isinstance(activation, str):

                inf = activations.get(activation)(inf)

          elif hasattr(activation, '__call__'):

                inf = activation(inf)

          else:

                raise error("Invalid Activation.")

       # Track activations.

       tf.add_to_collection(tf.GraphKeys.ACTIVATIONS, inf)

       # Add attributes to Tensor to easy access weights.

       inference.scope = scope

       inference.w = w

       inference.a = a

       # Track output tensor.

       tf.add_to_collection(tf.GraphKeys.LAYER_TENSOR + '/' + name, inf)

       return inf

What Users are saying..

profile image

Gautam Vermani

Data Consultant at Confidential
linkedin profile url

Having worked in the field of Data Science, I wanted to explore how I can implement projects in other domains, So I thought of connecting with ProjectPro. A project that helped me absorb this topic... Read More

Relevant Projects

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

Time Series Python Project using Greykite and Neural Prophet
In this time series project, you will forecast Walmart sales over time using the powerful, fast, and flexible time series forecasting library Greykite that helps automate time series problems.

Build OCR from Scratch Python using YOLO and Tesseract
In this deep learning project, you will learn how to build your custom OCR (optical character recognition) from scratch by using Google Tesseract and YOLO to read the text from any images.

Learn to Build Generative Models Using PyTorch Autoencoders
In this deep learning project, you will learn how to build a Generative Model using Autoencoders in PyTorch

Digit Recognition using CNN for MNIST Dataset in Python
In this deep learning project, you will build a convolutional neural network using MNIST dataset for handwritten digit recognition.

Build CNN Image Classification Models for Real Time Prediction
Image Classification Project to build a CNN model in Python that can classify images into social security cards, driving licenses, and other key identity information.

Learn How to Build PyTorch Neural Networks from Scratch
In this deep learning project, you will learn how to build PyTorch neural networks from scratch.

Locality Sensitive Hashing Python Code for Look-Alike Modelling
In this deep learning project, you will find similar images (lookalikes) using deep learning and locality sensitive hashing to find customers who are most likely to click on an ad.

Deep Learning Project for Time Series Forecasting in Python
Deep Learning for Time Series Forecasting in Python -A Hands-On Approach to Build Deep Learning Models (MLP, CNN, LSTM, and a Hybrid Model CNN-LSTM) on Time Series Data.

Learn to Build an End-to-End Machine Learning Pipeline - Part 2
In this Machine Learning Project, you will learn how to build an end-to-end machine learning pipeline for predicting truck delays, incorporating Hopsworks' feature store and Weights and Biases for model experimentation.