semvec/pypi-packages huggingface dataset:
ngclib 0.5
NGC Library
License: WTFPL
Requires Python: >=3.8

# Neural Graph Consensus library (ngclib)

This is a library containing the implementation of various basic blocks in the NGC project
- the base [NGC class](ngclib/models/ngc.py) as well as various implementations ([NGC-V1](ngclib/models/ngc_v1.py), [NGC-Ensemble](ngclib/models/ngc_ensemble.py))
- iterative trainer for the ngc ([sequential](ngclib/trainer/iteration_trainer/sequential_trainer.py), [parallel](ngclib/trainer/iteration_trainer/parallel_trainer.py))
- semisupervised generic [pseudolabels algorithm](ngclib/semisupervised/semisup.py)
- analysis of an [ngcdir](ngclib/ngcdir/ngcdir.py) for training and data status
- [nodes importer](ngclib/uitls/nodes_importer.py) -- required to import a repository of nodes containing the basic definition of all nodes and edges


Projects using this library:
- [Semi-Supervised Learning for Multi-Task Scene Understanding by Neural Graph Consensus](https://gitlab.com/neural-graph-consensus/semisup-multitask-scene-understanding) (accepted at AAAI2021)
python-simple-caching 0.3
Python Simple-Caching
License: WTFPL
Requires Python: >=3.8

# Simple Caching

Small project to standardize storing (key, value) data for caching purposes.

## Supported caching methods:
1. Disk
   - **NpyFS** - Numpy array export
2. Memory
   - **DictMemory** - keys are stored as dict keys and recalled from memory


## Example

```
from simple_caching.storage import MemoryDict
import numpy as np
import time

def working_fn(image: np.ndarray) -> np.ndarray:
   """Working function that takes on average 0.2s"""
   if np.random.rand() <= 0.2:
      time.sleep(1)
   return (image - image.min()) / (image.max() - image.min())

data = np.random.randn(32, 240, 420, 3).astype(np.float32) # 32 images of 240x420 shape

# Standard version. Takes 0.2s in average per epoch for the same processing.
for i in range(100):
   new_data = [working_fn(image) for image in data]
   # do further processing with the result

# Cached version. We store the result on memory.

def key_encode_fn(image: np.ndarray) -> str:
   """Return a cachable key for each image. We use a string of mean + std that should be unique enough."""
   return f"{image.mean()}_{image.std()}"

cache = DictMemory(name="images", key_encode_fn=key_encode_fn)
# alternative, use: cache.map(working_fn, data)
for image in data:
   cache[image] = working_fn(image)

for i in range(100):
   new_data = [cache[image] for image in data]
   # do further processing with the result
```

## Decoator version

```
@cache_fn(NpyFS, key_encode_fn)
def working_fn(image: np.ndarray) -> np.ndarray:
   """Working function that takes on average 0.2s"""
   if np.random.rand() <= 0.2:
      time.sleep(1)
   return (image - image.min()) / (image.max() - image.min())

def key_encode_fn(image: np.ndarray) -> str:
   """Return a cachable key for each image. We use a string of mean + std that should be unique enough."""
   return f"{image.mean()}_{image.std()}"

for i in range(100):
   new_data = working_fn(image)
   # do further processing with the result
```