{"id":16911164,"url":"https://github.com/kamo-naoyuki/pytorch_convolutional_rnn","last_synced_at":"2025-07-25T19:40:08.892Z","repository":{"id":58009500,"uuid":"131576450","full_name":"kamo-naoyuki/pytorch_convolutional_rnn","owner":"kamo-naoyuki","description":"PyTorch implementation of Convolutional Recurrent Neural Network","archived":false,"fork":false,"pushed_at":"2023-02-22T10:37:43.000Z","size":23,"stargazers_count":132,"open_issues_count":2,"forks_count":34,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-18T20:13:39.592Z","etag":null,"topics":["cnn","crnn","deep-learning","pytorch","rnn"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kamo-naoyuki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-30T09:16:17.000Z","updated_at":"2024-04-15T09:05:18.000Z","dependencies_parsed_at":"2024-10-27T12:14:58.826Z","dependency_job_id":"cb36cf58-418f-49f2-b898-db4ccc4cfdda","html_url":"https://github.com/kamo-naoyuki/pytorch_convolutional_rnn","commit_stats":{"total_commits":28,"total_committers":1,"mean_commits":28.0,"dds":0.0,"last_synced_commit":"7e0f32ee5eacec571b38527fbe24af61a161154c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamo-naoyuki%2Fpytorch_convolutional_rnn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamo-naoyuki%2Fpytorch_convolutional_rnn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamo-naoyuki%2Fpytorch_convolutional_rnn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamo-naoyuki%2Fpytorch_convolutional_rnn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kamo-naoyuki","download_url":"https://codeload.github.com/kamo-naoyuki/pytorch_convolutional_rnn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227553558,"owners_count":17786124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cnn","crnn","deep-learning","pytorch","rnn"],"created_at":"2024-10-13T19:04:43.045Z","updated_at":"2024-12-02T18:17:26.483Z","avatar_url":"https://github.com/kamo-naoyuki.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytorch_convolutional_rnn\n\nThe pytorch implemenation for convolutional rnn is alreaedy exisitng other than my module, for example.\n\n- https://github.com/ndrplz/ConvLSTM_pytorch\n- https://github.com/jacobkimmel/pytorch_convgru\n\nHowever, there are no modules supporting neither variable length tensor nor bidirectional rnn.\n\nI implemented ``AutogradConvRNN`` by referring to ``AutogradRNN`` at https://github.com/pytorch/pytorch/blob/master/torch/nn/_functions/rnn.py, so my convolutional RNN modules have similar structure to ``torch.nn.RNN`` and supports the above features as it has.\n\nThe benefit of using ``AutogradConvRNN`` is not only that it enables my modules to have the same interface as ``torch.nn.RNN``, but makes it very easy to implement many kinds of CRNN, such as ``CLSTM``, ``CGRU``.\n\n## Require\n- python3 (Not supporting python2 because I prefer type annotation)\n- pytorch0.4.0, python1.0.0\n\n## Feature\n- Implemented at python level, without any additional CUDA kernel, c++ codes.\n- Convolutional RNN, Convolutional LSTM, Convolutional Peephole LSTM, Convolutional GRU\n- Unidirectional, Bidirectional\n- 1d, 2d, 3d\n- Supporting PackedSequence (Supporting variable length tensor)\n- Supporting nlayers RNN and RNN Cell, both.\n- Not supporting different hidden sizes for each layers (But, it is very easy to implement it by stacking 1-layer-CRNNs)\n\n## Example\n- With `pack_padded_sequence`\n```python\nimport torch\nimport convolutional_rnn\nfrom torch.nn.utils.rnn import pack_padded_sequence\n\nin_channels = 2\nnet = convolutional_rnn.Conv3dGRU(in_channels=in_channels,  # Corresponds to input size\n                                  out_channels=5,  # Corresponds to hidden size\n                                  kernel_size=(3, 4, 6),  # Int or List[int]\n                                  num_layers=2,\n                                  bidirectional=True,\n                                  dilation=2, stride=2, dropout=0.5)\nlength = 3\nbatchsize = 2\nlengths = [3, 1]\nshape = (10, 14, 18)\nx = pack_padded_sequence(torch.randn(length, batchsize, in_channels, *shape), lengths, batch_first=False)\nh = None\ny, h = net(x, h)\n```\n\n- Without `pack_padded_sequence`\n```python\nimport torch\nimport convolutional_rnn\nfrom torch.nn.utils.rnn import pack_padded_sequence\n\nin_channels = 2\nnet = convolutional_rnn.Conv2dLSTM(in_channels=in_channels,  # Corresponds to input size\n                                   out_channels=5,  # Corresponds to hidden size\n                                   kernel_size=3,  # Int or List[int]\n                                   num_layers=2,\n                                   bidirectional=True,\n                                   dilation=2, stride=2, dropout=0.5,\n                                   batch_first=True)\nlength = 3\nbatchsize = 2\nshape = (10, 14)\nx = torch.randn(batchsize, length, in_channels, *shape)\nh = None\ny, h = net(x, h)\n```\n\n- With `Cell`\n```python\nimport torch\nimport convolutional_rnn\ncell = convolutional_rnn.Conv2dLSTMCell(in_channels=3, out_channels=5, kernel_size=3).cuda()\ntime = 6\ninput = torch.randn(time, 16, 3, 10, 10).cuda()\noutput = []\nfor i in range(time):\n    if i == 0:\n        hx, cx = cell(input[i])\n    else:\n        hx, cx = cell(input[i], (hx, cx))\n    output.append(hx)\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamo-naoyuki%2Fpytorch_convolutional_rnn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamo-naoyuki%2Fpytorch_convolutional_rnn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamo-naoyuki%2Fpytorch_convolutional_rnn/lists"}