generate reliable relu activation function for DNNs
Project description
Reliable ReLU Toolbox (RReLU) To Enhance Resilience of DNNs
Background • Usage • Code • Citation •
Background
The Reliable ReLU Toolbox (RReLU) is a powerful reliability tool designed to enhance the resiliency of deep neural networks (DNNs) by generating reliable ReLU activation functions. It is Implemented for the popular PyTorch deep learning platform. RReLU allows users to find a clipped ReLU activation function using various methods. This tool is highly versatile for dependability and reliability research, with applications ranging from resiliency analysis of classification networks to training resilient models and improving DNN interpretability.
RReLU includes all state-of-the-art activation restriction methods. These methods offer several advantages: they do not require retraining the entire model, avoid the complexity of fault-aware training, and are non-intrusive, meaning they do not necessitate any changes to an accelerator. RReLU serves as the research code accompanying the paper (ProAct: Progressive Training for Hybrid Clipped Activation Function to Enhance Resilience of DNNs), and it includes implementations of the following algorithms:
- ProAct (the proposed algorithm) (code).
- FitAct (paper and code).
- FtClipAct (paper and code).
- Ranger (paper and code).
Usage
you can download the rrelu on PyPI here.
Installing
From Pip
Install using pip install rrelu
From Source Download this repository into your project folder.
Importing
Import the entire package:
import rrelu
In order to use multiple gpu :
pip install torchpack
from torchpack import distributed as dist
dist.init()
torch.backends.cudnn.benchmark = True
torch.cuda.set_device(dist.local_rank())
create a model :
from rrelu.setup import build_model
model = build_model("model_name":string, n_classes:inetger,dropout_rate:float).cuda()
create a data loader :
from rrelu.setup import build_data_loader
data_loader_dict, n_classes = build_data_loader(
dataset:string,
image_size,
batch_size,
n_worker,
data_path,
dist.size(), # for multiple gpu
dist.rank(), # for multiple gpu
)
load pretrained model :
checkpoint = load_state_dict_from_file(args.init_from)
model.load_state_dict(checkpoint)
change the representatoin to fixed-point :
for name, param in model.named_parameters():
if param!=None:
param.copy_(torch.tensor(Fxp(param.clone().cpu().numpy(), True, n_word=args.n_word,n_frac=args.n_frac,n_int=args.n_int).get_val()))
replace activatoin function with clipped version :
from rrelu.setup import replace_act
model = replace_act(model,args.name_relu_bound,args.name_serach_bound,data_loader_dict,args.bounds_type,args.bitflip)
evaluate the clipped model on various fault rates :
from rrelu.setup import eval_fault
for fault_rate in args.fault_rates: # fault_rates = [10^-7,3 * 10^-7 ,10^-6 , 3 * 10^-6 , 10^-5 , 3 * 10^-5]
val_results_fault = eval_fault(model,data_loader_dict,fault_rate,args.iterations,args.bitflip,args.n_word , args.n_frac, args.n_int)
Import a specific module:
from rrelu.search_bound import proact_bounds
run search in command line
When Download this repository into your project folder.
torchpack dist-run -np 1 python search.py --dataset "dataset name (CIFAR10, CIFAR100)" --data_path "path to the dataset" --model "name of the model" --init_from "pretrained file path" \
--name_relu_bound "name of bounded relu" --name_serach_bound "name of the search algorithm" --bounds_type "type of thresholds" --bitflip "value representaiton"
Code
Structure
The main source code of framework is held in src/rrelu, which carries search_bounds, relu_bounds , extended pytorchfi and other implementations.
Citation
View the published paper. If you use or reference rrelu, please cite:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rrelu-0.1.0.tar.gz.
File metadata
- Download URL: rrelu-0.1.0.tar.gz
- Upload date:
- Size: 34.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
909198951e5b2ff055a89b1ed6a654ea94a291186e073a876b9322bb205d28ad
|
|
| MD5 |
dad8c95a94ecf4fe383f3d8cbb6af9ef
|
|
| BLAKE2b-256 |
be7f8acf887d0672241fd80681e4dbe19fe0983a6a086be5dd68de1b34c728a1
|
File details
Details for the file rrelu-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rrelu-0.1.0-py3-none-any.whl
- Upload date:
- Size: 49.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
687e439c0b98a9ba6792651b84cdacdc535f9804831974ddcd0a888eab6db554
|
|
| MD5 |
4ff6f55407fd44f33cbfedeccc628be8
|
|
| BLAKE2b-256 |
3e00ce0d375f7ecd6d7d435d3d7b2462c22ea6fa432a0f57c0b957a74003d0a9
|