{"id":15065398,"url":"https://github.com/r-papso/pynet","last_synced_at":"2026-02-26T08:18:34.622Z","repository":{"id":45242825,"uuid":"440247656","full_name":"r-papso/pynet","owner":"r-papso","description":"Deep learning library implemented in Python","archived":false,"fork":false,"pushed_at":"2021-12-28T23:46:08.000Z","size":81,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-24T10:56:37.550Z","etag":null,"topics":["deep-learning","machine-learning","neural-network","numpy","python"],"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/r-papso.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":"2021-12-20T17:07:14.000Z","updated_at":"2021-12-28T23:46:11.000Z","dependencies_parsed_at":"2022-09-09T22:51:17.351Z","dependency_job_id":null,"html_url":"https://github.com/r-papso/pynet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/r-papso/pynet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-papso%2Fpynet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-papso%2Fpynet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-papso%2Fpynet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-papso%2Fpynet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-papso","download_url":"https://codeload.github.com/r-papso/pynet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-papso%2Fpynet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267332873,"owners_count":24070444,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-network","numpy","python"],"created_at":"2024-09-25T00:37:56.081Z","updated_at":"2026-02-26T08:18:29.578Z","avatar_url":"https://github.com/r-papso.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pynet\n\nPynet is a Python library containing all of the deep learning building blocks.\n\n## Features\n\n### _Tensor operations_\n\nTensor operations are included in the [pynet.functional](./pynet/functional) namespace. Pynet provides a couple of basic tensor operations such as matrix multiplication or tensor addition. New tensor operation can be created by implementing the [Function](./pynet/functional/abstract.py) abstract class. Tensor functions that are included in the library are:\n\n- Tensor addition [[link]](./pynet/functional/add.py)\n- Matrix multiplication [[link]](./pynet/functional/matmul.py)\n- Element-wise maximum [[link]](./pynet/functional/max.py)\n- Element-wise sigmoid [[link]](./pynet/functional/sigmoid.py)\n\n### _Neural network layers and activation functions_\n\nImplementation of neural network layers and activation functions are included in the [pynet.nn](./pynet/nn) namespace. The namespace contains basic layer and activation function implementations and can be extended by implementing the [Module](./pynet/nn/abstract.py) abstract class. List of layers and activation functions included in the Pynet library:\n\n- Fully connected layer (Linear) [[link]](./pynet/nn/linear.py)\n- Sequential module (container for other modules) [[link]](./pynet/nn/sequential.py)\n- Rectified linear unit (ReLU) activation function [[link]](./pynet/nn/relu.py)\n- Sigmoid activation function [[link]](./pynet/nn/sigmoid.py)\n\n### _Loss functions_\n\nLoss function implementations are included in the [pynet.loss](./pynet/loss) namespace. Custom loss functions can be created by implementing the [Loss](./pynet/loss/abstract.py) abstract class. Loss functions included in the Pynet library are:\n\n- Binary cross entropy [[link]](./pynet/loss/bce.py)\n- Mean squared error [[link]](./pynet/loss/mse.py)\n\n### _Optimization algorithms_\n\nOptimization algorithm implementations are included in the [pynet.optimizers](./pynet/optimizers) namespace. New optimization algorithm can be created by implementing the [Optimizer](./pynet/optimizers/abstract.py) abstract class. Optimization algorithms included in the library:\n\n- Stochastic Gradient Descent (SGD) [[link]](./pynet/optimizers/sgd.py)\n\n### _Data manipulation_\n\n[pynet.data](./pynet/data) namespace provides abstraction over the datasets used for training the neural network. [In-memory](./pynet/data/in_memory.py) dataset implementation is already included in the library, however one can create their own dataset implementation by extending the [Dataset](./pynet/data/abstract.py) abstract class.\n\n### _Neural network training_\n\nFor the neural network's training/testing procedure, one can either use default implementation of these procedures, which can be found in the [DefaultTrainer](./pynet/training/trainer/default.py) class or implement their own training/testing logic by extending the [Trainer](./pynet/training/trainer/abstract.py) abstract class. One can also omit both these options and implement its own logic from scratch (for example, see the [DefaultTrainer](./pynet/training/trainer/default.py) train and test function implementations).\n\nWhen using one of the [Trainer](./pynet/training/trainer/abstract.py)'s implementations, a [Callback](./pynet/training/callbacks/abstract.py) class was created to perform additional actions at various stages of training/testing procedure. There are a couple of callbacks implemented and ready to use, such as:\n\n- Callback providing printing all the measured model's metrics onto the console ([PrintCallback](./pynet/training/callbacks/print.py))\n- Callback providing optimizer's learning rate scheduling ([LrSchedule](./pynet/training/callbacks/lr_schedule.py))\n\nOne can also easily create their own callback by extending the [Callback](./pynet/training/callbacks/abstract.py) abstract class.\n\n### _Summary_\n\nTable below summarizes the feature section. Every row of a table contains name of the namespace, namespace description (what functionality this namespace provides) and a way of extending this functionality (by implementing the abstract class).\n\n| Namespace                                              | Functionality                                     | Abstract class                                     |\n| ------------------------------------------------------ | ------------------------------------------------- | -------------------------------------------------- |\n| [pynet.functional](./pynet/functional)                 | Tensor operations                                 | [Function](./pynet/functional/abstract.py)         |\n| [pynet.nn](./pynet/nn)                                 | Neural network layers and activation functions    | [Module](./pynet/nn/abstract.py)                   |\n| [pynet.loss](./pynet/loss)                             | Loss functions                                    | [Loss](./pynet/loss/abstract.py)                   |\n| [pynet.optimizers](./pynet/optimizers)                 | Optimization algorithms                           | [Optimizer](./pynet/optimizers/abstract.py)        |\n| [pynet.data](./pynet/data)                             | Data manipulation                                 | [Dataset](./pynet/data/abstract.py)                |\n| [pynet.training.trainer](./pynet/training/trainer)     | Neural network training/testing procedure         | [Trainer](./pynet/training/trainer/abstract.py)    |\n| [pynet.training.callbacks](./pynet/training/callbacks) | Callback functions during the training/testing    | [Callback](./pynet/training/callbacks/abstract.py) |\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install pynet.\n\n```bash\npip install pynet-dl\n```\n\n## Usage\n\nHere is the simple example how to use the Pynet library. In this example we are going to train a very small neural network on the make_circles dataset from sklearn.dataset package.\n\n### _Training_\n\nFirst, we need to import all the necessary stuff:\n\n```python\nimport numpy as np\n\nfrom sklearn.datasets import make_circles\n\n# Tensor class\nfrom pynet.tensor import Tensor\n\n# Neural network modules\nfrom pynet.nn.sequential import Sequential\nfrom pynet.nn.linear import Linear\nfrom pynet.nn.relu import ReLU\nfrom pynet.nn.sigmoid import Sigmoid\n\n# Datasets\nfrom pynet.data.in_memory import InMemoryDataset\n\n# Loss functions\nfrom pynet.loss.bce import BinaryCrossEntropy\n\n# Optimizers\nfrom pynet.optimizers.sgd import SGD\n\n# Weight initializers\nfrom pynet.initializers.he_normal import HeNormal\n\n# Trainer and training/testing callbacks\nfrom pynet.training.trainer.default import DefaultTrainer\nfrom pynet.training.callbacks.print import PrintCallback\n```\n\nThen, load the dataset and do preprocessing. As the single input to the neural network (i. e. sample xi) is supposed to be of shape [n_features x 1] (i. e. column vector), we need to add one extra dimension to the X array:\n\n```python\nX, y = make_circles(n_samples=1000, noise=0.025)\n# inputs to neural net must be of shape [n, 1]\nX = np.expand_dims(X, axis=2)\n```\n\nThen, we will create the network, dataset, optimizer, appropriate loss function, trainer and optionally also specify a list of callbacks:\n\n```python\nepochs = 20\n\nmodel = Sequential([\n    Linear(inputs=2, neurons=16, initializer=HeNormal()),\n    ReLU(),\n    Linear(inputs=16, neurons=1, initializer=HeNormal()),\n    Sigmoid()\n])\n\ndataset = InMemoryDataset(X, y)\nloss_f = BinaryCrossEntropy()\nsgd = SGD(learning_rate=0.01, momentum=0.9)\ncallbacks = [PrintCallback(), LrSchedule(optimizer=sgd, schedule=lr_schedule)]\ntrainer = DefaultTrainer()\n```\n\nAnd then run the training:\n\n```python\ntrainer.train(\n    model=model,\n    train_dataset=dataset,\n    val_dataset=None,\n    loss_f=loss_f,\n    optimizer=sgd,\n    epochs=epochs,\n    callbacks=callbacks\n)\n```\n\n### _Inference_\n\nAfter training the neural network, we can use it for inference.\n\n```python\n# Make prediction for the i-th sample in the dataset\ni = 0\ny_pred = model.forward(Tensor(X[i])).ndarray.item()\n```\n\n## Examples\n\nMore examples of the Pynet library usage can be found in the [notebooks](./notebooks) directory.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-papso%2Fpynet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-papso%2Fpynet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-papso%2Fpynet/lists"}