{"id":14970728,"url":"https://github.com/x-raylaser/multi-directional-mdrnn","last_synced_at":"2025-10-26T13:31:17.343Z","repository":{"id":57440461,"uuid":"240732165","full_name":"X-rayLaser/multi-directional-mdrnn","owner":"X-rayLaser","description":"Custom Keras layers for implementing multi-dimensional recurrent neural networks (MDRNNs) described in Alex Graves's paper https://arxiv.org/pdf/0705.2011.pdf","archived":false,"fork":false,"pushed_at":"2020-04-27T15:35:40.000Z","size":111,"stargazers_count":10,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-25T08:02:50.050Z","etag":null,"topics":["deep-learning","keras","lstm","machine-learning","mdrnn","multi-dimensional-rnn","neural-networks","paper-implementations","recurrent-neural-networks","rnn","tensorflow"],"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/X-rayLaser.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}},"created_at":"2020-02-15T15:00:01.000Z","updated_at":"2024-11-16T04:37:47.000Z","dependencies_parsed_at":"2022-09-19T17:10:27.082Z","dependency_job_id":null,"html_url":"https://github.com/X-rayLaser/multi-directional-mdrnn","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-rayLaser%2Fmulti-directional-mdrnn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-rayLaser%2Fmulti-directional-mdrnn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-rayLaser%2Fmulti-directional-mdrnn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-rayLaser%2Fmulti-directional-mdrnn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/X-rayLaser","download_url":"https://codeload.github.com/X-rayLaser/multi-directional-mdrnn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238337303,"owners_count":19455285,"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":["deep-learning","keras","lstm","machine-learning","mdrnn","multi-dimensional-rnn","neural-networks","paper-implementations","recurrent-neural-networks","rnn","tensorflow"],"created_at":"2024-09-24T13:44:03.256Z","updated_at":"2025-10-26T13:31:11.942Z","avatar_url":"https://github.com/X-rayLaser.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi-Directional Multi-Dimensional Recurrent Neural Networks\n\nA library built on top of TensorFlow implementing the model described in\nAlex Graves's paper https://arxiv.org/pdf/0705.2011.pdf.\nThe library comes with a set of custom Keras layers.\nEach layer can be seamlessly used in Keras to build a model and\ntrain it as usual.\n\n# Status: under development\n\nThis repository is in its early stages. The code presented here is not stable yet\nand it wasn't extensively tested. Use it at your own risk\n\n# Features\n\nLayers available now:\n- **MDRNN**: layer analogous to Keras SimpleRNN layer for processing multi-dimensional inputs\n- **MDLSTM**: analogous to Keras LSTM layer\n- **MultiDirectional**: layer-wrapper analogous to Keras Bidirectional for creating \nmulti-directional multi-dimensional RNN\n\nLayers currently under development (coming soon):\n- **MDGRU**: analogous to Keras GRU layer\n\nAdditional features:\n- easy to use with Keras\n- Keras-like API for each layer\n- option to choose order/direction in which to process inputs\n- computations are run on CPU\n\n# Installation\nInstall the package from PyPI:\n```\npip install mdrnn\n```\n\nAlternatively, clone the repository and install dependencies:\n```\ngit clone \u003crepo_url\u003e\ncd \u003crepo_directory\u003e\npip install -r requirements.txt\n```\n\n# Quick Start\n\nCreate a 2-dimensional RNN:\n```\nfrom mdrnn import MDRNN, MDLSTM, MultiDirectional\nimport numpy as np\nimport tensorflow as tf\nrnn = MDRNN(units=16, input_shape=(5, 4, 10), activation='tanh', return_sequences=True)\noutput = rnn(np.zeros((1, 5, 4, 10)))\n```\n\nBuild a Keras model consisting of 1 MDRNN layer and train it:\n\n```\nmodel = tf.keras.Sequential()\nmodel.add(MDRNN(units=16, input_shape=(2, 3, 6), activation='tanh'))\nmodel.add(tf.keras.layers.Dense(units=10, activation='softmax'))\nmodel.compile(loss='categorical_crossentropy', metrics=['acc'])\nmodel.summary()\nx = np.zeros((10, 2, 3, 6))\ny = np.zeros((10, 10,))\nmodel.fit(x, y)\n```\n\nSimilarly, create and train a multi-directional MDRNN\n```\nx = np.zeros((10, 2, 3, 6))\ny = np.zeros((10, 40,))\n\nmodel = tf.keras.Sequential()\nmodel.add(tf.keras.layers.Input(shape=(2, 3, 6)))\nmodel.add(MultiDirectional(MDRNN(10, input_shape=[2, 3, 6])))\n\nmodel.compile(loss='categorical_crossentropy', metrics=['acc'])\nmodel.summary()\n\nmodel.fit(x, y, epochs=1)\n```\n\nSimilarly, create and train a multi-directional multi-dimensional LSTM (MDLSTM)\n```\nx = np.zeros((10, 2, 3, 6))\ny = np.zeros((10, 40,))\n\nmodel = tf.keras.Sequential()\nmodel.add(tf.keras.layers.Input(shape=(2, 3, 6)))\nmodel.add(MultiDirectional(MDLSTM(10, input_shape=[2, 3, 6])))\n\nmodel.compile(loss='categorical_crossentropy', metrics=['acc'])\nmodel.summary()\n\nmodel.fit(x, y, epochs=1)\n```\n\n\n# Requirements\n\n- TensorFlow version \u003e= 2.0\n\n# References\n\n[1] A. Graves, S. Ferńandez, and J. Schmidhuber. Multidimensional recurrent neural networks.\n\n[2] A. Graves and J. Schmidhuber. Offline Handwriting Recognition with Multidimensional Recurrent Neural Networks.\n\n# Support\n\nIf you find this repository useful, consider starring it by clicking at the ★ button. It would be much appreciated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-raylaser%2Fmulti-directional-mdrnn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fx-raylaser%2Fmulti-directional-mdrnn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-raylaser%2Fmulti-directional-mdrnn/lists"}