Coder Social home page Coder Social logo

convgru-pytorch's Introduction

ConvLSTM_pytorch

This file contains the implementation of Convolutional LSTM in PyTorch

How to Use

The ConvGRU module derives from nn.Module so it can be used as any other PyTorch module.

The ConvGRU class supports an arbitrary number of stacked hidden layers in GRU. In this case, it can be specified the hidden dimension (that is, the number of channels) and the kernel size of each layer. In the case more layers are present but a single value is provided, this is replicated for all the layers. For example, in the following snippet each of the three layers has a different hidden dimension but the same kernel size.

Example usage:

# set CUDA device
os.environ["CUDA_VISIBLE_DEVICES"] = "3"

# detect if CUDA is available or not
use_gpu = torch.cuda.is_available()
if use_gpu:
    dtype = torch.cuda.FloatTensor # computation in GPU
else:
    dtype = torch.FloatTensor

height = width = 6
channels = 256
hidden_dim = [32, 64]
kernel_size = (3,3) # for two stacked hidden layers with same kernel_size or write as [(3,3), (3,3)]
num_layers = 2 # number of stacked hidden layer
model = ConvGRU(input_size=(height, width),
                input_dim=channels,
                hidden_dim=hidden_dim,
                kernel_size=kernel_size,
                num_layers=num_layers,
                dtype=dtype,
                batch_first=True,
                bias = True,
                return_all_layers = False)

batch_size = 1
time_steps = 1
input_tensor = torch.rand(batch_size, time_steps, channels, height, width)  # (b,t,c,h,w)
layer_output_list, last_state_list = model(input_tensor)

Disclaimer

This is still a work in progress and is far from being perfect: if you find any bug please don't hesitate to open an issue.

License

ConvLSTM_pytorch is released under the MIT License (refer to the LICENSE file for details).

Acknowledgment

This repo borrows some codes from

convgru-pytorch's People

Contributors

happyjin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.