semvec/pypi-packages huggingface dataset:
powertorch 0.1.0
A collection of PyTorch utilities designed to streamline the deep learning workflows
Requires Python: >=3.10

# PowerTorch

A collection of PyTorch utilities designed to streamline the deep learning workflows

## Getting Started

### Installation

You can install the library directly from the repository:

```shell
pip install git+https://github.com/yutingshih/powertorch.git
```

Alternatively, clone the repository and manually install the dependencies:

```shell
git clone https://github.com/yutingshih/powertorch.git
cd nth
pip install -r requirements.txt
```

### Quick Test

To verify the installation, run the MNIST example:

```python
python3 -m examples.mnist
```

## Usage

### Import Package

```python
from powertorch import helper
from powertorch import models
```

### Prepare Data

```python
trainloader, validloader = helper.prepare_data(
    source=torchvision.datasets.MNIST,
    train=True,
    batch_size=256,
    transform=transforms.ToTensor(),
    splits=[0.8, 0.2],
)

testloader = helper.prepare_data(
    source=torchvision.datasets.MNIST,
    train=False,
    batch_size=256,
    transform=transforms.ToTensor(),
)
```

### Define a Training Task

```python
losses = []
def train_step(batch, index, epoch):
    net.train()
    optimizer.zero_grad()
    inputs, labels = [i.to(device) for i in batch]
    outputs = net(inputs)
    loss = criterion(outputs, labels)
    loss.backward()
    optimizer.step()
    losses.append(loss.item())

trainer = helper.Task(train_step)
trainer.run(trainloader, max_epochs=max_epochs)
```

### Register Event Handlers

#### Show Progress

```python
trainer = helper.Task(train_step)
trainer.add_event_handler(helper.Event.ITERATION_STARTED,
    lambda: print(f'Progress: {trainer.state.batch}/{len(trainloader)}', end='\r'))
trainer.run(trainloader, max_epochs=max_epochs)
```

#### Evaluate Model

```python
def evaluate_model(dataloader):
    # (skip) ...

trainer = helper.Task(train_step)
trainer.add_event_handler(helper.Event.EPOCH_COMPLETED, evaluate_model, testloader)
trainer.run(trainloader, max_epochs=max_epochs)
```
nnfigs 0.2.2
Draw neural network figures with Matplotlib
Requires Python: >=3.11

======================
Neural Network Figures
======================

Copyright (c) 2017-2024 Jérémie DECOCK <jd.jdhp@gmail.com> (www.jdhp.org)

* Web site: https://gitlab.com/jdhp-dev/neural-network-figures
* Online documentation: https://jdhp-dev.gitlab.io/neural-network-figures/
* Examples: https://jdhp-dev.gitlab.io/neural-network-figures/gallery/
* Source code: https://gitlab.com/jdhp-dev/neural-network-figures
* Issue tracker: https://gitlab.com/jdhp-dev/neural-network-figures/issues
* Pytest code coverage: https://jdhp-dev.gitlab.io/neural-network-figures/htmlcov/index.html
* Neural Network Figures on PyPI: https://pypi.org/project/nnfigs


Table of Contents
=================

.. contents::
   :depth: 2


Description
===========

Draw neural network figures with Matplotlib

Note:

    This project is still in beta stage, so the API is not finalized yet.


Dependencies
============

Neural Network Figures requires Python 3.11 (or newer) and Python packages listed in the `requirements.txt` file.


.. _install:

Installation (development environment)
======================================

Posix (Linux, MacOSX, WSL, ...)
-------------------------------

From the Neural Network Figures source code::

    conda deactivate         # Only if you use Anaconda...
    python3 -m venv env
    source env/bin/activate
    python3 -m pip install --upgrade pip
    python3 -m pip install -r requirements-dev.txt


Windows
-------

From the Neural Network Figures source code::

    conda deactivate         # Only if you use Anaconda...
    python3 -m venv env
    env\Scripts\activate.bat
    python3 -m pip install --upgrade pip
    python3 -m pip install -r requirements-dev.txt


Installation (production environment)
=====================================

::

    pip install nnfigs


Documentation
=============

* Online documentation: https://jdhp-dev.gitlab.io/neural-network-figures
* API documentation: https://jdhp-dev.gitlab.io/neural-network-figures/api.html


Build and run the Python Docker image
=====================================

Build the docker image
----------------------

From the Neural Network Figures source code::

    docker build -t nnfigs:latest .

Run unit tests from the docker container
----------------------------------------

From the Neural Network Figures source code::

    docker run nnfigs pytest

Run an example from the docker container
----------------------------------------

From the Neural Network Figures source code::

    docker run nnfigs python3 /app/examples/hello.py


Bug reports
===========

To search for bugs or report them, please use the Neural Network Figures Bug Tracker at:

    https://gitlab.com/jdhp-dev/neural-network-figures/issues


License
=======

This project is provided under the terms and conditions of the `MIT License`_.


.. _MIT License: http://opensource.org/licenses/MIT
.. _command prompt: https://en.wikipedia.org/wiki/Cmd.exe