{"id":15753569,"url":"https://github.com/marella/nn","last_synced_at":"2025-04-30T15:10:35.529Z","repository":{"id":57446451,"uuid":"236025709","full_name":"marella/nn","owner":"marella","description":"A neural network library built on top of TensorFlow for quickly building deep learning models.","archived":false,"fork":false,"pushed_at":"2020-01-27T12:01:36.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-16T03:37:24.173Z","etag":null,"topics":["deep-learning","machine-learning","neural-networks","nn","python","tensorflow"],"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/marella.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-01-24T15:14:07.000Z","updated_at":"2024-02-14T02:08:46.000Z","dependencies_parsed_at":"2022-09-02T22:11:29.703Z","dependency_job_id":null,"html_url":"https://github.com/marella/nn","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/marella%2Fnn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marella%2Fnn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marella%2Fnn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marella%2Fnn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marella","download_url":"https://codeload.github.com/marella/nn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229510834,"owners_count":18084444,"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","machine-learning","neural-networks","nn","python","tensorflow"],"created_at":"2024-10-04T07:41:12.040Z","updated_at":"2024-12-13T08:05:15.075Z","avatar_url":"https://github.com/marella.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"A neural network library built on top of TensorFlow for quickly building deep learning models.\n\n[![Build Status](https://travis-ci.org/marella/nn.svg?branch=master)](https://travis-ci.org/marella/nn)\n\n## Usage\n\n`nn.Tensor` is the core data structure which is a wrapper for `tf.Tensor` and provides additional functionality. It can be created using the `nn.tensor()` function:\n\n```py\nimport nn\n\na = nn.tensor([1, 2, 3])\nassert isinstance(a, nn.Tensor)\nassert a.shape == (3, )\n```\n\nIt supports method chaining:\n\n```py\nc = a.square().sum()\nassert c.numpy() == 14\n```\n\nand can be used with `tf.Tensor` objects:\n\n```py\nimport tensorflow as tf\n\nb = tf.constant(2)\nc = (a - b).square().sum()\nassert c.numpy() == 2\n```\n\nIt can also be used with high level APIs such as `tf.keras`:\n\n```py\nmodel = nn.Sequential([\n  nn.Dense(128, activation='relu'),\n  nn.Dropout(0.2),\n  nn.Dense(10)\n])\n\ny = model(x)\nassert isinstance(y, nn.Tensor)\n```\n\nand to perform automatic differentiation and optimization:\n\n```py\noptimizer = nn.Adam()\nwith nn.GradientTape() as tape:\n    outputs = model(inputs)\n    loss = (targets - outputs).square().mean()\ngrads = tape.gradient(loss, model.trainable_variables)\noptimizer.apply_gradients(zip(grads, model.trainable_variables))\n```\n\nTo use it with ops that expect `tf.Tensor` objects as inputs, wrap the ops using `nn.op()`:\n\n```py\nmean = nn.op(tf.reduce_mean)\nc = mean(a)\nassert isinstance(c, nn.Tensor)\n\nmaximum = nn.op(tf.maximum, binary=True)\nc = maximum(a, b)\nassert isinstance(c, nn.Tensor)\n```\n\nor convert it to a `tf.Tensor` object using the `tf()` method or `nn.tf()` function:\n\n```py\nb = a.tf()\nassert isinstance(b, tf.Tensor)\n\nb = nn.tf(a)\nassert isinstance(b, tf.Tensor)\n```\n\nSee more examples [here][examples].\n\n## Installation\n\nRequirements:\n\n-   TensorFlow \u003e= 2.0\n-   Python \u003e= 3.6\n\nInstall from PyPI (recommended):\n\n```sh\npip install nn\n```\n\nAlternatively, install from source:\n\n```sh\ngit clone https://github.com/marella/nn.git\ncd nn\npip install -e .\n```\n\n[TensorFlow] should be installed separately.\n\n## Testing\n\nTo run tests, install dependencies:\n\n```sh\npip install -e .[tests]\n```\n\nand run:\n\n```sh\npytest tests\n```\n\n[tensorflow]: https://www.tensorflow.org/install\n[examples]: https://github.com/marella/train/tree/master/examples\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarella%2Fnn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarella%2Fnn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarella%2Fnn/lists"}