semvec/pypi-packages huggingface dataset:
PyAutoFact 0.0.1
Auto Factorization package for PyTorch modules
Requires Python: >=3.3

# PyAutoFact
### Automatic factorization library for pytorch

<img src="img/pytorch-logo-dark.png" width="10%"> [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 

If you use any source codes included in this toolkit in your work, please cite the following paper.
- Winata, G. I., Cahyawijaya, S., Lin, Z., Liu, Z., & Fung, P. (2019). Lightweight and Efficient End-to-End Speech Recognition Using Low-Rank Transformer. arXiv preprint arXiv:1910.13923. (Accepted in ICASSP 2020)

### What is PyAutoFact
PyAutoFact is a library to convert `Linear`, `Conv1d`, `Conv2d`, `Conv3d` layers into its own variant which called `LED`.
PyAutoFact seeks over your PyTorch module, replace all `Linear` layers into `LED` layers and all `Conv1d`, `Conv2d`, `Conv3d` layers into `CED` layers with the specified rank.

### How to Install
```
pip install PyAutoFact
```

### Usage
##### BERT Model
```
from transformers import BertModel, BertConfig
from py_auto_fact import auto_fact

config = BertConfig.from_pretrained('bert-base-uncased', pretrained=False)
model = BertModel(config=config)

model = auto_fact(model, rank=100, deepcopy=False, ignore_lower_equal_dim=True, fact_led_unit=False)
```

##### VGG Model
```
import torch
from torchvision import models
from py_auto_fact import auto_fact

model = models.vgg16()
model = auto_fact(model, rank=64, deepcopy=False, ignore_lower_equal_dim=True, fact_led_unit=False)
```

### Why Use PyAutoFact
- Improve the speed of you model significantly, check our [Example Notebook](https://github.com/SamuelCahyawijaya/py_auto_fact/blob/main/examples/factorize_bert.ipynb)
- Mantain model performance with appropriate choice of rank, check our [ICASSP 2020 Paper](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=9053878)
- Easy to use and works on any kind of model!
print-debugging 0.0.2
Load module, function from string

Debug and Release the code with same code
=========================================

Do not use print for debugging and delete print for release

Example Usage
-------------
::

  from printDebugging import *
  setLevel(DEBUG) # or setLevel("DEBUG")
  debug("hi")     # printed out
  setLevel(QUIET) # set debug level into QUIET
  debug("hi")     # not printed out

  # Configure Color
  set_color("purple", INFO)         # set foreground color as purple  for info
  set_color("WHITE", WARN, "bg")    # set backgournd color as white for warn
  add_style("underline", DEBUG)
  reset_style(WARN)
  reset_style()

  # Configure Prefix
  setLevel(INFO)
  set_prefixes("{trace}", INFO)   # Add string as prefix for INFO
  info("HI")                      # FileName with Line number is printed out as prefix
  import datetime
  set_prefixes(datetime.datetime.now) # Add function with no parameter as prefix
  info("hello")                   # Result of `datetime.datetime.now()` is printed out as prefix

  # Configure postfix
  import traceback
  set_postfixes(traceback.format_exc, ERROR)
  try:
    0 / 0
  except:
    error("Expected Error")             # traceback is printed out

Debug Level
-----------
- QUIET : DO NOT PRINT EXCEPT "error"
- INFO  : Print info and error
- VERBOSE : Print info, warn and error
- DEBUG : print info, warn, error and debug

TO DO
-----
Add function with arugment as prefix or postfix