How dependablesystemslab/tensorfi2 works
Project type and purpose
• This is an open-source Python library/tool (TensorFI2) for injecting faults into TensorFlow 2/Keras models. It is not a full-stack web app but a standalone fault-injection framework with accompanying experiments and case studies.
File structure
• Top-level files:
• README.md, LICENSE, CONTRIBUTING.md, requirements.txt
• src/: the core injector implementation (tensorfi2 logic, config loader)
• conf/: YAML schema and default configurations for injection modes
• experiments/: example scripts showing dynamic (layer-outputs) and static (layer-states) injection methods, plus model checkpoints under experiments/*/h5
• case-studies/: higher-level end-to-end examples (traffic recognition, image segmentation) using the tool
• test-suite/: validation tests for injector correctness
• Patterns:
• src/tensorfi2.py implements the Injector API
• Configuration‐driven design: YAML → config parser → injection pipeline
• Plug-in style: user code calls tfi.inject(…) around Keras model
README for additional insights
• Architecture section describes two injection targets: layer states (static) and layer outputs (dynamic).
• Usage: import the library, call inject(model, confFile) before inference.
Relationships and interactions
• User Application → loads a Keras model → trains it
• User Application → imports TensorFI2 → calls inject(…)
• Injector Engine ← reads YAML config
• Injector Engine ↔ TensorFlow Model Graph (hooks into layers)
• Fault Types Module used by Injector Engine at injection points
• Results written to output directories (CSV, plots)
• Experiments/Case Studies use this pipeline end-to-end
• Test Suite separately invokes parts of the Injector Engine with mock models
Architectural patterns and design principles
• Configuration-driven: decouples injection logic from user code
• Dependency-inversion: Injector Engine interfaces with high‐level Keras APIs, not low‐level framework internals
• Plugin/Hook pattern: runtime wrapping of layer methods
• Separation of concerns: core library vs. examples vs. configs vs. tests
Relevant technologies, frameworks, or libraries
• Python 3.x
• TensorFlow 2 / Keras
• PyYAML for config parsing
• numpy
• h5py (via TensorFlow) for model files
Detailed capture of essential elements
• Don’t just group “src” as a blob—break it into Config Loader, Injector Engine, Fault Types
• Experiments and case-studies as client-applications invoking the core