Coder Social home page Coder Social logo

saitejamalyala / injecttfparallel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abirami-mygithub/injecttfparallel

0.0 1.0 0.0 28.38 MB

InjectTFParallel is a python based software that helps to test the reliability of non-sequential deep learning models. Hardware faults like bit flips, flip to all zeroes can be simulated with the help of this software. One can specify the layer name where the fault is to be injected, fault type and probability of fault injection in a configuration file in yaml format. The model is evaluated with the fault injected into the specified layer and accuracy, loss and confusion matrix is computed. Intermediate layer outputs can also be visualized, so as to get better understanding of the overall behavior of the model while injecting fault.

License: MIT License

Python 100.00%

injecttfparallel's Introduction

InjectTFParallel

InjectTFParallel is a fault injection software for simulating hardware faults to evaluate the reliability of non-sequential deep learning models (i.e Deep learning models with branches).
For example: [ResNet50], [InceptionV3], [MobileNetV2]


Table of Contents


Description

InjectTFParallel software provides us fault injection functionality to test the resilience of deep learning models against hardware faults. InjectTF2 is a fault injection software for sequential models. InjectTFParallel mainly focuses on injecting fault into non-sequential models (i.e) model containing layers with more than one input or one output. In InjectTFParallel, fault injection into a model is done by creating a duplicate copy of the model and inserting fault injection custom layers. Two types of faults namely random bit fault and specific bit fault can be injected using InjectTFParallel. Each of these faults have unique custom layer implementation. Based on the chosen fault type, appropriate custom layer is inserted into duplicate copy of the model(also called as fault model). Fault model is then evaluated on the test dataset.

Keract library is used to visualize intermediate layer outputs in order to understand the behaviour of the model on fault injection.

Back To The Top


Getting Started

Prerequisites

  • Python (v3.x.x)

Installation

  • Clone the repository using following command.
$ git clone https://github.com/Abirami-mygithub/InjectTFParallel.git
  • Create a virtual environment inside the cloned repository folder (InjectTFParallel).
$ python3 -m venv .venv
  • Activate the created virtual environment
$ source .venv/bin/activate
  • Install the dependencies from requirements.txt
$ pip install -r requirements.txt --no-cache-dir

How to use

  1. Import fault injector component
 from injecttf.fault_injector import Fault_Injector
  1. Instantiate fault injector component
 fi_obj = Fault_Injector()
  1. Call inject_fault() from fault injector component using the instantiated object.
 fi_obj.inject_fault()

example.py is created to show the usage of InjectTFParallel fault injector.


Implementation Details

InjectTFParallel software architecture mainly comprises of configuration manager, model trainer, fault injector, model creator, datasets, custom layer, evaluation and visualization components. Each of these components have individual responsibility and interact with each other to provide the fault injection functionality.

  • Configuration Manager: It is responsible for reading from the config file containing fault injection specification and provide the fault injection configuration on request. It provides the config data in python dictionary.

  • Model Creator: It provides the model architecture based on the user's request .

  • Dataset: It provides preprocessed mnist and gtsrb dataset

  • Model Trainer: It fetches the model from model creator and dataset, trains the model if not saved weights are available. It provides model and the weights .

  • Custom Layer: Fault injection is done through creating custom layers. Two different custom layers namely Fault_Injector_Random_Bit and Fault_Injector_Specific_Bit is created. Each has its own functionality.

  • Fault Injector: It is responsible for creating a duplicate copy of the model for which fault is to be injected and based on the fault injection specification from config file, inserts appropriate fault injection custom layer into the duplicate copy of the model. Thereby a new fault model is created with fault injection custom layer. This fault model is compiled and evaluated.

Software Architecture

Software Architecture

Sequence Diagram

Sequence Diagram

Back To The Top


Results

Model architecture without fault

Model architecture without fault

Model architecture with fault

Model architecture with fault

Fault Type - Specific bit

Accuracy loss bit number constant

Fault Type - Random bit

Probability Accuracy Loss
100% 0.1009 2.3602
90% 0.2026 2.2574
80% 0.0958 2.3653
70% 0.9598 1.5011
50% 0.9235 1.5678
40% 0.9630 1.4982

Back To The Top


Possible Issues and Solutions

  1. Error while loading the weights from .h5 file
    Downgrade h5py to < 3.0.0 by following command:
$ pip install 'h5py<3.0.0'

References

[1] He, Kaiming, et al. "Deep residual learning for image recognition." Proceedings of the IEEE conference on computer vision and pattern recognition. 2016.
[2] Szegedy, Christian, et al. "Rethinking the inception architecture for computer vision." Proceedings of the IEEE conference on computer vision and pattern recognition. 2016.
[3] Sandler, Mark, et al. "Mobilenetv2: Inverted residuals and linear bottlenecks." Proceedings of the IEEE conference on computer vision and pattern recognition. 2018.

Back To The Top


License

MIT License

Copyright (c) 2021 Abirami Ravi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Author Info

Acknowledgements

Back To The Top


injecttfparallel's People

Contributors

abirami-mygithub avatar abirami-ravi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.