Skip to content

Commit

Permalink
examples: updated training YML to be more condensed and understandable
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsextonMITRE committed Sep 11, 2024
1 parent 00b7de5 commit a8c9137
Show file tree
Hide file tree
Showing 18 changed files with 2,060 additions and 252 deletions.
43 changes: 31 additions & 12 deletions examples/mnist-classifier-demo/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"metadata": {
"tags": []
},
Expand All @@ -41,7 +41,7 @@
"EXPERIMENT_DESC = \"applying the fast gradient sign (FGM) attack to a classifier trained on MNIST\"\n",
"QUEUE_NAME = 'tensorflow_cpu'\n",
"QUEUE_DESC = 'Tensorflow CPU Queue'\n",
"PLUGIN_FILES = '../task-plugins/dioptra_custom/vc/'\n",
"PLUGIN_FILES = '../task-plugins/dioptra_custom/fgm_mnist_demo/'\n",
"MODEL_NAME = \"mnist_classifier\"\n",
"\n",
"# Default address for accessing the RESTful API service\n",
Expand All @@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -176,7 +176,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"metadata": {
"tags": []
},
Expand All @@ -194,9 +194,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 23,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[2m2024-09-11 15:28:38\u001b[0m [\u001b[31m\u001b[1merror \u001b[0m] \u001b[1mError code 400 returned. \u001b[0m \u001b[36mdata\u001b[0m=\u001b[35m{'username': 'pluginuser', 'email': '[email protected]', 'password': 'pleasemakesuretoPLUGINthecomputer', 'confirmPassword': 'pleasemakesuretoPLUGINthecomputer'}\u001b[0m \u001b[36mmethod\u001b[0m=\u001b[35mPOST\u001b[0m \u001b[36mresponse\u001b[0m=\u001b[35m{\"message\": \"Bad Request - The username on the registration form is not available. Please select another and resubmit.\"}\n",
"\u001b[0m \u001b[36murl\u001b[0m=\u001b[35mhttp://localhost:20080/api/v1/users/\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"{'username': 'pluginuser', 'status': 'Login successful'}"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"try:\n",
" client.users.create('pluginuser','[email protected]','pleasemakesuretoPLUGINthecomputer','pleasemakesuretoPLUGINthecomputer')\n",
Expand All @@ -214,7 +233,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -240,13 +259,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 45,
"metadata": {},
"outputs": [],
"source": [
"experiment_id, train_ep, queue_id = upload_experiment(client, 'src/train.yml','train','training a classifier on MNIST', PLUGIN_FILES, QUEUE_NAME, QUEUE_DESC, EXPERIMENT_NAME, EXPERIMENT_DESC)\n",
"experiment_id, fgm_ep, queue_id = upload_experiment(client, 'src/fgm.yml','fgm','generating examples on mnist_classifier using the fgm attack', PLUGIN_FILES, QUEUE_NAME, QUEUE_DESC, EXPERIMENT_NAME, EXPERIMENT_DESC)\n",
"experiment_id, infer_ep, queue_id = upload_experiment(client, 'src/infer.yml','infer','evaluating performance of mnist_classifier on generated fgm examples', PLUGIN_FILES, QUEUE_NAME, QUEUE_DESC, EXPERIMENT_NAME, EXPERIMENT_DESC)"
"#experiment_id, fgm_ep, queue_id = upload_experiment(client, 'src/fgm.yml','fgm','generating examples on mnist_classifier using the fgm attack', PLUGIN_FILES, QUEUE_NAME, QUEUE_DESC, EXPERIMENT_NAME, EXPERIMENT_DESC)\n",
"#experiment_id, infer_ep, queue_id = upload_experiment(client, 'src/infer.yml','infer','evaluating performance of mnist_classifier on generated fgm examples', PLUGIN_FILES, QUEUE_NAME, QUEUE_DESC, EXPERIMENT_NAME, EXPERIMENT_DESC)"
]
},
{
Expand All @@ -260,7 +279,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 46,
"metadata": {
"scrolled": true
},
Expand All @@ -275,7 +294,7 @@
" train_ep, \n",
" {\"epochs_p\":\"1\"}, \n",
" job_time_limit\n",
")\n"
")"
]
},
{
Expand Down
76 changes: 59 additions & 17 deletions examples/mnist-classifier-demo/src/fgm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,75 @@ parameters:
seed_p: -1

tasks:
init_rng:
plugin: dioptra_custom.vc.random_rng.init_rng
load_dataset:
plugin: dioptra_custom.fgm_mnist_demo.plugins.load_dataset
inputs:
- name: seed
- name: ep_seed
type: integer
required: false
- name: data_dir
type: string
required: false
- name: subset
type: str_null
required: false
- name: image_size
type: image_size
required: false
- name: rescale
type: number
required: false
- name: validation_split
type: num_null
required: false
- name: batch_size
type: integer
required: false
- name: label_mode
type: string
required: false
- name: shuffle
type: boolean
required: false
outputs:
- ret1: integer
- ret2: rng
dataset: directory_iterator

draw_random_integer:
plugin: dioptra_custom.vc.random_sample.draw_random_integer
get_model:
plugin: dioptra_custom.fgm_mnist_demo.plugins.get_model
inputs:
- rng: rng
- name: low
type: integer
- name: dataset
type: directory_iterator
required: false
- name: high
type: integer
- name: model_architecture
type: string
required: false
- name: input_shape
type: image_size
required: false
- name: loss
type: string
required: false
- name: learning_rate
type: number
required: false
- name: optimizer
type: string
required: false
- name: metrics_list
type: metrics_list
required: false
- name: uri
type: string
required: false
- name: imagenet_preprocessing
type: boolean
required: false
- name: classifier_kwargs
type: kwargs
required: false
outputs:
value: integer
classifier: sequential

init_tensorflow:
plugin: dioptra_custom.vc.backend_configs_tensorflow.init_tensorflow
inputs:
- seed: integer

make_directories:
plugin: dioptra_custom.vc.artifacts_utils.make_directories
Expand Down
Loading

0 comments on commit a8c9137

Please sign in to comment.