Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #53 from iotcad/rename
Browse files Browse the repository at this point in the history
rename src -> aml
  • Loading branch information
nkrusch authored Jun 15, 2023
2 parents f1120a5 + 160a28f commit 68e11f1
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 53 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@ DATASETS := DS_1 DS_2
query:
@$(foreach i, $(LIMIT), $(foreach c, $(CLS), $(foreach r, $(ROBUST), \
$(foreach attack, $(ATTACKS), $(foreach ds, $(DATASETS), \
python3 -m src experiment $(ALWAYS) --out output/query -a $(attack) $($(ds)) $($(r)) \
python3 -m aml experiment $(ALWAYS) --out output/query -a $(attack) $($(ds)) $($(r)) \
--iter $(i) -c $(c) ; )))))

sample:
@$(foreach c, $(CLS), $(foreach r, $(ROBUST), $(foreach attack, $(ATTACKS), \
python3 -m src experiment $(ALWAYS) --out output/sample -a $(attack) $(DS_2) $($(r)) \
python3 -m aml experiment $(ALWAYS) --out output/sample -a $(attack) $(DS_2) $($(r)) \
--iter 0 -s $(SAMPLE) -t $(TIMES) -c $(c) ; )))

valid:
@$(foreach file, $(wildcard $(DATA_DIR)/CTU*), \
python3 -m src validate -d $(file) --validator IOT23 --capture;)
python3 -m aml validate -d $(file) --validator IOT23 --capture;)
@$(foreach file, $(wildcard $(DATA_DIR)/nb15*), \
python3 -m src validate -d $(file) --validator NB15 --capture;)
python3 -m aml validate -d $(file) --validator NB15 --capture;)

plot:
@python3 -m src plot $(RESDIR)
@python3 -m aml plot $(RESDIR)

plots:
@python3 -m src plot output/query && python3 -m src plot output/sample
@python3 -m aml plot output/query && python3 -m aml plot output/sample

lint:
flake8 ./src --count --show-source --statistics
flake8 ./aml --count --show-source --statistics

clean:
@rm -fr output/
Expand Down
28 changes: 28 additions & 0 deletions aml/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# flake8: noqa: F401

"""
Adversarial machine learning in network setting.
"""

__title__ = "aml"
__author__ = ""
__license__ = "MIT"
__version__ = "1.0.0"

import os
import warnings

warnings.filterwarnings("ignore")
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

# noinspection PyPep8Naming
from aml.utility import show as Show, show_ratio as Ratio, sdiv
from aml.validator import Validator
from aml.classifier import Classifier
from aml.attack import Attack
from aml.dnn import NeuralNetwork
from aml.xgb import XgBoost
from aml.hopskip import HopSkip
from aml.zoo import Zoo
from aml.experiment import Experiment
from aml.plotter import plot_results as Plot
11 changes: 6 additions & 5 deletions src/__main__.py → aml/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
Usage:
```
python -m src
python -m aml
```
List all available options:
```
python -m src --help
python -m aml --help
```
"""
Expand All @@ -23,7 +23,7 @@
from sys import exit
from typing import Optional, List

from src import __version__, __title__, \
from aml import __version__, __title__, \
Experiment, Validator, Plot, utility


Expand All @@ -39,15 +39,16 @@ def main():
choice = [args.which if hasattr(args, 'which')
else None] * len(options)
is_exp, is_vld, is_plot = [a == b for a, b in zip(choice, options)]
init_logger(logging.FATAL if args.silent else logging.DEBUG)
init_logger(logging.FATAL if 'silent' in args and args.silent
else logging.DEBUG)
if hasattr(args, 'out'):
utility.ensure_dir(args.out)

if is_plot:
Plot(args.dir, args.format)
return

if not args.dataset:
if 'dataset' not in args or not args.dataset:
parser.print_help()
exit(1)

Expand Down
2 changes: 1 addition & 1 deletion src/attack.py → aml/attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import numpy as np

from src import Classifier, Validator, utility
from aml import Classifier, Validator, utility


class Attack:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/dnn.py → aml/dnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from art.estimators.classification import KerasClassifier
from art.defences.trainer import AdversarialTrainer

from src import Classifier, utility
from aml import Classifier, utility

tf.compat.v1.disable_eager_execution()
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
Expand Down
2 changes: 1 addition & 1 deletion src/experiment.py → aml/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from sklearn.model_selection import KFold

# noinspection PyUnresolvedReferences
from src import Classifier, Attack, Validator, utility, \
from aml import Classifier, Attack, Validator, utility, \
HopSkip, Zoo, NeuralNetwork, XgBoost, Show, Ratio, sdiv, machine

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/hopskip.py → aml/hopskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np
from art.attacks.evasion import HopSkipJump as ARTHopSkipJump

from src import Attack, utility
from aml import Attack, utility


class HopSkip(Attack):
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/plotter.py → aml/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import pandas as pd
from pytablewriter import SpaceAlignedTableWriter, LatexTableWriter

from src import sdiv
from src.utility import rarr, rget
from aml import sdiv
from aml.utility import rarr, rget

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/validator.py → aml/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pathlib import Path
from typing import Tuple, Union, List

from src import Show, utility
from aml import Show, utility


class Protocol:
Expand Down
2 changes: 1 addition & 1 deletion src/xgb.py → aml/xgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# noinspection PyPackageRequirements
from xgboost import DMatrix, train as xg_train

from src import Classifier
from aml import Classifier


class XgBoost(Classifier):
Expand Down
2 changes: 1 addition & 1 deletion src/zoo.py → aml/zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from art.attacks.evasion import ZooAttack

from src import Attack, utility
from aml import Attack, utility


class Zoo(Attack):
Expand Down
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,25 @@ validate - Check a dataset for network protocol correctness
Custom experiments can be defined by constructing appropriate commands.
```
python3 -m src {experiment|plot|validate} [ARGS]
python3 -m aml {experiment|plot|validate} [ARGS]
```
To see available options for experiments, run:
```
python3 -m src experiment --help
python3 -m aml experiment --help
```
To see available options for plotting results, run:
```
python3 -m src plot --help
python3 -m aml plot --help
```
To see available options for the validator, run:
```
python3 -m src validate --help
python3 -m aml validate --help
```
For native execution see [these instructions](https://github.com/iotcad/aml-networks/blob/main/.github/CONTRIBUTING.md).
28 changes: 0 additions & 28 deletions src/__init__.py

This file was deleted.

0 comments on commit 68e11f1

Please sign in to comment.