A toolkit for automated DNN repair.
- python >= 3.8
- pip >= 21.3
$ python -m venv <path/to/venv>
$ source <path/to/venv>/bin/activate
(venv-name) $ pip install --upgrade pip
(venv-name) $ pip install -e .
Note
See tutorial for an example usage with concrete DNN model and dataset. See user manual for details.
The following items should be given in typical machine learning contexts.
model: a DNN model (to be repaired)dataset_test: a dataset for testingmodel(and those repaired)
Let dataset_test_A be a subset of dataset_test containing data labelled ''A''.
(venv-name) $ repair test \
--model_dir=${model} \
--data_dir=${dataset_test_A}
...
accuracy: XX.XX%
If this XX.XX% does not satisfy your requirements for model (e.g., YY.YY% or larger), this toolkit can be used for repairing it.
This toolkit additionally requires:
dataset_repair: an additional dataset for repairingmodel. This contents should be different from those indataset_test(and a training dataset as well) to prevent overfitting.
This toolkit has a functionality to generate subsets of dataset_repair that model succeeds and fails to predict on each label.
(venv-name) $ repair target \
--model_dir=${model} \
--data_dir=${dataset_repair}
Let dataset_repair_A_neg be the subset that model fails to predict on the label ''A''.
In addition, let dataset_repair_pos be the subset that model succeeds to predict on all labels (called as a ''positive subset'').
Here you need to select a repair method to be applied.
method: a repair method implemented in this toolkit. See the list of repair methods
Run this toolkit to localize suspicious neural weights in model which may cause misprediction on the label ''A''.
(venv-name) $ repair localize \
--method=${method} \
--model_dir=${model} \
--target_data_dir=${dataset_A_neg}
Then, run it again to optimize the localized weights while preventing degradation in model by using the positive subset.
(venv-name) $ repair optimize \
--method=${method} \
--model_dir=${model} \
--target_data_dir=${dataset_repair_A_neg} \
--positive_inputs_dir={dataset_repair_pos}
Finally, this toolkit outputs a DNN model model_repaired that is a repaired candidate of model.
Let's check it.
(venv-name) $ repair test \
--model_dir=${model_repaired} \
--data_dir=${dataset_test_A}
...
accuracy: ZZ.ZZ%
If this ZZ.ZZ% is greater than the YY.YY%,
you can obtain model_repaired that satisfies your requirements,
indicating this toolkit worked to repair model!
Please read CONTRIBUTING for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Yuta Maezawa (Udzuki/NII)
- Fuyuki Ishikawa (NII)
- Nobukazu Yoshioka (Waseda/NII)
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details.
We quote the license below because some tests and tutorial involve the data and labels of BDD100K.
Copyright ©2018. The Regents of the University of California (Regents). All Rights Reserved.
THIS SOFTWARE AND/OR DATA WAS DEPOSITED IN THE BAIR OPEN RESEARCH COMMONS REPOSITORY ON 1/1/2021
Permission to use, copy, modify, and distribute this software and its documentation for educational, research, and not-for-profit purposes, without fee and without a signed licensing agreement; and permission to use, copy, modify and distribute this software for commercial purposes (such rights not subject to transfer) to BDD and BAIR Commons members and their affiliates, is hereby granted, provided that the above copyright notice, this paragraph and the following two paragraphs appear in all copies, modifications, and distributions. Contact The Office of Technology Licensing, UC Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620, (510) 643-7201, otl@berkeley.edu, http://ipira.berkeley.edu/industry-info for commercial licensing opportunities.
IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED “AS IS”. REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- This work was supported by JST-Mirai Program Grant Number JPMJMI18BB, Japan.
© 2023 eAI Project