{"id":16858783,"url":"https://github.com/titu1994/keras-non-local-nets","last_synced_at":"2025-04-05T20:08:18.837Z","repository":{"id":150946854,"uuid":"111765562","full_name":"titu1994/keras-non-local-nets","owner":"titu1994","description":"Keras implementation of Non-local Neural Networks","archived":false,"fork":false,"pushed_at":"2024-05-13T05:00:38.000Z","size":273,"stargazers_count":290,"open_issues_count":8,"forks_count":97,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-29T19:05:29.248Z","etag":null,"topics":["convolutional-neural-networks","keras","neural-network","non-local"],"latest_commit_sha":null,"homepage":null,"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/titu1994.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":"2017-11-23T05:04:13.000Z","updated_at":"2024-08-12T19:34:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"5520d0b3-e63b-4243-93b3-30f43a859f31","html_url":"https://github.com/titu1994/keras-non-local-nets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/titu1994%2Fkeras-non-local-nets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/titu1994%2Fkeras-non-local-nets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/titu1994%2Fkeras-non-local-nets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/titu1994%2Fkeras-non-local-nets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/titu1994","download_url":"https://codeload.github.com/titu1994/keras-non-local-nets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393570,"owners_count":20931813,"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":["convolutional-neural-networks","keras","neural-network","non-local"],"created_at":"2024-10-13T14:15:10.619Z","updated_at":"2025-04-05T20:08:18.812Z","avatar_url":"https://github.com/titu1994.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Keras Non-Local Neural Networks\nKeras implementation of Non-local blocks from [[1]](https://arxiv.org/abs/1711.07971).\n\n- Support for `\"Gaussian\"`, `\"Embedded Gaussian\"` and `\"Dot\"` instantiations of the Non-Local block. \n- Support for variable shielded computation mode (reduces computation by N**2 x, where N is default to 2)\n- Support for `\"Concatenation\"` instantiation will be supported when authors release their code.\n\n# Usage Templates\n\nThe script `non_local.py` contains the `NonLocalBlock` instance which takes in an input tensor and wraps a non-local block around it.\n\n```python\nfrom non_local import NonLocalBlock\nfrom tensorflow.keras.layers import Input, Conv1D, Conv2D, Conv3D\n\nip = Input(shape=(...))  # input tensor with an \"N\" rank order of 3, 4 or 5\nx = ConvND(...)         # convolution operation with aforementioned rank \n...\nnon_local_block = NonLocalBlock(intermediate_dim=None, compression=2, mode='embedded', add_residual=True)\nx = non_local_block(x)\n...\n```\n\nThe script `non_local_layerstyle.py` contains the `NonLocalBlock` **layer** which takes in an input tensor and wraps a non-local block around it. Made to facilitate the neural network builder using the Sequential method. \n\n```python\nfrom non_local_layerstyle import NonLocalBlock\nfrom tensorflow.keras.layers import Input, Conv1D, Conv2D, Conv3D\n\n# Define the input shape\ninput_shape = (...)  # shape of input tensor\n\nmodel = Sequential()\nmodel.add(ConvND(...))         # convolution operation with an \"N\" rank order of 3, 4 or 5\n...\nmodel.add(NonLocalBlock(intermediate_dim=None, compression=2, mode='embedded', add_residual=True))\n...\n```\n\n\n# Basic block\nFrom [[1]](https://arxiv.org/abs/1711.07971), a basic Non-Local block with the Embedded Gaussian instantiation has the below logic:\n\n\n\n\u003ccenter\u003e\u003cimg src=\"https://github.com/titu1994/keras-non-local-nets/blob/master/images/non-local-block.PNG?raw=true\" width=50% \u003e\u003c/center\u003e\n\n\n1. Xiaolong Wang, Ross Girshick, Abhinav Gupta, Kaiming He. \"Non-local Neural Networks.\" arXiv:1711.07971 [cs.CV], 21 Nov 2017. [Link](https://arxiv.org/abs/1711.07971)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftitu1994%2Fkeras-non-local-nets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftitu1994%2Fkeras-non-local-nets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftitu1994%2Fkeras-non-local-nets/lists"}