How to use time distributed layer in TF learn

This recipe helps you use time distributed layer in TF learn

Recipe Objective

This recipe explains how to use time distributed layer in TFLayer.

Learn How to use XLNet for Text Classification

Time Distributed

Its syntax is: tflearn.layers.core.time_distributed (incoming, fn, args=None, scope=None)
where its arguments are incoming which is The incoming tensor, fn which is a function to apply at every timestep, args which is a list of parameters to use with the provided function and, scope which is a scope to give to each timestep tensor.
At every timestep function of input tensor a layer is applied.

def Time_Distributed(ic, fn, args=None, s=None):

    if not args:
       args = list()
    assert isinstance(args, list), "'args' must be a list."
    if not isinstance(ic, tf.Tensor):
       ic = tf.transpose(tf.stack(ic), [1, 0, 2])

    ip = utils.get_incoming_shape(ic)
    time = input_shape[1]
    y = tf.unstack(ic, axis=1)
    if s:
       y = [fn(y[i], scope=s+'-'+str(i), *args) for i in range(time)]
    else:
       y = [fn(y[i], *args) for i in range(time)]
    y = list(map(lambda t: tf.reshape(t, [-1, 1]+utils.get_incoming_shape(t)[1:]), y))
    return tf.concat(y, 1)

What Users are saying..

profile image

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Azure Deep Learning-Deploy RNN CNN models for TimeSeries
In this Azure MLOps Project, you will learn to perform docker-based deployment of RNN and CNN Models for Time Series Forecasting on Azure Cloud.

BigMart Sales Prediction ML Project in Python
The goal of the BigMart Sales Prediction ML project is to build and evaluate different predictive models and determine the sales of each product at a store.

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

Recommender System Machine Learning Project for Beginners-3
Content Based Recommender System Project - Building a Content-Based Product Recommender App with Streamlit

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.

Build an End-to-End AWS SageMaker Classification Model
MLOps on AWS SageMaker -Learn to Build an End-to-End Classification Model on SageMaker to predict a patient’s cause of death.

Time Series Forecasting Project-Building ARIMA Model in Python
Build a time series ARIMA model in Python to forecast the use of arrival rate density to support staffing decisions at call centres.

AWS MLOps Project to Deploy a Classification Model [Banking]
In this AWS MLOps project, you will learn how to deploy a classification model using Flask on AWS.

Build a Graph Based Recommendation System in Python-Part 2
In this Graph Based Recommender System Project, you will build a recommender system project for eCommerce platforms and learn to use FAISS for efficient similarity search.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.