# TorchEI
**Repository Path**: torchei/TorchEI
## Basic Information
- **Project Name**: TorchEI
- **Description**: TorchEI, 一个围绕DNN Reliability的研究和开发的高速工具包
- **Primary Language**: Python
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 5
- **Forks**: 2
- **Created**: 2022-06-27
- **Last Updated**: 2024-04-03
## Categories & Tags
**Categories**: machine-learning
**Tags**: None
## README
TorchEI⚡
------
## Introduction
👋TorchEI, 发音为*/ˈtôrCHər/*(like torture), 是Pytorch Error Injection的缩写, 一个围绕DNN Reliability 研究的高速工具箱. TorchEI 使您能够快速简单地将错误注入 DNN,收集您需要的信息并强化您的 DNN。
## Features
- 完善的类型提示和文档支持
- 包含来自 DNN 可靠性论文的方法
- 高度定制化
## Quick Example
在这里,我们将向您展示一个简单的示例,或者您可以尝试 [interactive demo](https://colab.research.google.com/github/TorchEI/TorchEI/blob/main/example.ipynb) 和[online editor](https://github.dev/TorchEI/TorchEI)
#### Installing
你可以使用 `pip3 install torchei` 安装或 [下载](https://github.com/TorchEI/TorchEI/archive/refs/heads/main.zip)
#### Example
初始化故障模型
```python
import torch
from torchvision import models
import torchei
model = models.resnet18(pretrained=True)
data = torch.load('data/ilsvrc_valid8.pt')
fault_model = torchei.fault_model(model,data)
```
使用emat方法计算可靠性
```python
fault_model.emat_attack(10,1e-3)
```
使用[SERN](https://dl.acm.org/doi/abs/10.1145/3386263.3406938)方法计算可靠性
```python
fault_model.sern_calc(output_class=1000)
```
使用ODR方法加固DNN
```python
fault_model.outlierDR_protection()
fault_model.emat_attack(10,1e-3)
```
## Contribution

如果您发现🧐任何错误或有🖐️任何建议,请告诉我们。
这个 repo 欢迎所有想要一起维护的人。
You can helps us with follow things:
- PR your implemented methods in your or others' papers
- Complete our project
- Translate our docs to your language
- Other
我们希望将 TorchEI 构建为 DNN 可靠性方面的最佳工具箱,用于位翻转、对抗性攻击等。
:e-mail: forcessless@foxmail.com
## Citation
Our paper is under delivering.
## License
> [MIT](https://github.com/TorchEI/TorchEI/blob/main/LICENSE) License.
> Copyright:copyright:2022/5/23-present, Hao Zheng.