From b7206d2d4c2a861d427f590919e3750ff18d55c8 Mon Sep 17 00:00:00 2001 From: Seyong Kim Date: Sun, 5 May 2024 15:54:26 +0900 Subject: [PATCH] Update README.md --- README.md | 60 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index c393c88..7db03f7 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,12 @@ This repository contains the implementation of a bidirectional Convolutional LSTM (ConvLSTM) in PyTorch, as described in the paper [Convolutional LSTM Network: A Machine Learning Approach for Precipitation Nowcasting](https://arxiv.org/abs/1506.04214). The ConvLSTM model is particularly useful for spatiotemporal predictions where both spatial and temporal dynamics need to be captured. ## Features -- Implementation of ConvLSTM with bidirectional capability. -- Suitable for tasks like video frame prediction, anomaly detection in videos, and other spatiotemporal sequence prediction tasks. +- Implements bidirectional ConvLSTM, allowing the model to capture both forward and backward temporal dependencies +- Supports batch processing and variable sequence lengths +- Provides configurable parameters for input channels, hidden channels, kernel size, padding, stride, and bias +- Includes a custom `ConvGate` module for efficient computation of gate activations +- Compatible with PyTorch's `nn.Module` and can be easily integrated into existing PyTorch models + ## Environment Setup - Python 3.8 @@ -13,7 +17,6 @@ This repository contains the implementation of a bidirectional Convolutional LST To set up your environment to run the code, you can follow these steps: ``` -bash conda create --name convlstm python=3.8 conda activate convlstm pip install torch==1.13 torchvision @@ -21,32 +24,31 @@ pip install torch==1.13 torchvision ### Basic Example ``` -from model import ConvLSTM -import torch - -# Example parameters -input_channels = 3 -hidden_channels = 16 -kernel_size = (3, 3) -padding = (1, 1) -stride = (1, 1) -bias = True -batch_first = True -bidirectional = True - -model = ConvLSTM( - in_channels=input_channels, - hidden_channels=hidden_channels, - kernel_size=kernel_size, - padding=padding, - stride=stride, - bias=bias, - batch_first=batch_first, - bidirectional=bidirectional +from bidirectional_conv_lstm import ConvLSTM + +# Create a ConvLSTM instance +conv_lstm = ConvLSTM( + in_channels=1, + hidden_channels=64, + kernel_size=3, + padding=1, + stride=1, + bias=True, + batch_first=True, + bidirectional=True ) -# Example input tensor -batch_size, seq_len, height, width = 1, 10, 64, 64 -x = torch.rand(batch_size, seq_len, input_channels, height, width) -output, (hidden_state, cell_state) = model(x) +# Forward pass +input_tensor = torch.randn(batch_size, seq_len, in_channels, height, width) +output, (hidden_state, cell_state) = conv_lstm(input_tensor) ``` + +### References + +Shi, X., Chen, Z., Wang, H., Yeung, D. Y., Wong, W. K., & Woo, W. C. (2015). Convolutional LSTM network: A machine learning approach for precipitation nowcasting. In Advances in neural information processing systems (pp. 802-810). [arXiv:1506.04214] + +### Contributing +Contributions to this repository are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request. + +### License +This project is licensed under the MIT License.