Skip to content

Commit

Permalink
examples: added validation for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsextonMITRE committed Aug 30, 2023
1 parent 9fda3ec commit 23b2b38
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 35 deletions.
4 changes: 2 additions & 2 deletions examples/tensorflow-mnist-classifier/src/MLproject
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ entry_points:
norm: { type: string, default: "inf" }
seed: { type: float, default: -1 }
command: >
PYTHONPATH=$DIOPTRA_PLUGIN_DIR run-experiment fgm.yml
PYTHONPATH=$DIOPTRA_PLUGIN_DIR validate-experiment fgm.yml && PYTHONPATH=$DIOPTRA_PLUGIN_DIR run-experiment fgm.yml
-P data_dir={data_dir}
-P image_size={image_size}
-P adv_tar_name={adv_tar_name}
Expand All @@ -55,7 +55,7 @@ entry_points:
adv_data_dir: { type: string, default: "adv_testing" }
seed: { type: float, default: -1 }
command: >
PYTHONPATH=$DIOPTRA_PLUGIN_DIR run-experiment infer.yml
PYTHONPATH=$DIOPTRA_PLUGIN_DIR validate-experiment infer.yml && PYTHONPATH=$DIOPTRA_PLUGIN_DIR run-experiment infer.yml
-P run_id={run_id}
-P image_size={image_size}
-P model_name={model_name}
Expand Down
24 changes: 15 additions & 9 deletions examples/tensorflow-mnist-classifier/src/fgm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ types:
image_size:
tuple: [integer, integer, integer]
norm:
union: [integer, float, string]
union: [integer, number, string]

parameters:
data_dir: /dioptra/data/Mnist/testing
Expand All @@ -37,7 +37,7 @@ parameters:
adv_data_dir: adv_testing
distance_metrics_filename: distance_metrics.csv
model_name: mnist_le_net
model_version: "1"
model_version: 1
clip_values: [0, 1]
batch_size: 32
eps: 0.3
Expand Down Expand Up @@ -89,9 +89,13 @@ tasks:
load_classifier:
plugin: dioptra_builtins.registry.art.load_wrapped_tensorflow_keras_classifier
inputs:
- name: string
- name: name
type: string
required: true
- version: integer
- classifier_kwargs: kwargs_null
- name: classifier_kwargs
type: kwargs
required: false
outputs:
classifier: keras_classifier

Expand All @@ -113,7 +117,7 @@ tasks:
type: distance_metrics_null
required: false
- name: rescale
type: float
type: number
required: false
- name: batch_size
type: integer
Expand All @@ -122,13 +126,13 @@ tasks:
type: string
required: false
- name: eps
type: float
type: number
required: false
- name: eps_step
type: float
type: number
required: false
- name: minimal
type: bool
type: boolean
required: false
- name: norm
type: norm
Expand All @@ -144,7 +148,9 @@ tasks:
- name: tarball_write_mode
type: string
required: false
- working_dir: path_string_null
- name: working_dir
type: path_string_null
required: false

upload_artifact_dataframe:
plugin: dioptra_builtins.artifacts.mlflow.upload_data_frame_artifact
Expand Down
33 changes: 15 additions & 18 deletions examples/tensorflow-mnist-classifier/src/infer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ types:
rng:
path:
sequential:
number_null:
union: [number, "null"]
string_null:
union: [string, "null"]
path_string:
Expand All @@ -18,23 +20,15 @@ types:
kwargs_null:
union: [kwargs, "null"]
keras_classifier:
distance_metric_request:
mapping: [string, string]
distance_metrics_requests:
list: distance_metric_request
eval_metric:
mapping: [string, any]
eval_metric_results:
mapping: [string, float]
distance_metrics:
list: distance_metric
distance_metrics_null:
union: [distance_metrics, "null"]
mapping: [string, number]
dataframe:
image_size:
tuple: [integer, integer, integer]
norm:
union: [integer, float, string]
union: [integer, number, string]



Expand All @@ -44,7 +38,7 @@ parameters:
adv_tar_name: testing_adversarial_fgm.tar.gz
adv_data_dir: adv_testing
model_name: mnist_le_net
model_version: "1"
model_version: 1
seed: -1


Expand Down Expand Up @@ -96,7 +90,7 @@ tasks:
extract_tarfile:
plugin: dioptra_builtins.artifacts.utils.extract_tarfile
inputs:
- filepath:
- filepath: path_string
- name: tarball_read_mode
type: string
required: false
Expand All @@ -108,14 +102,14 @@ tasks:
plugin: dioptra_builtins.data.tensorflow.create_image_dataset
inputs:
- data_dir: string
- subset: str_null
- subset: string_null
- image_size: image_size
- seed: integer
- name: rescale
type: float
type: number
required: false
- name: validation_split
type: float
type: number_null
required: false
- name: batch_size
type: integer
Expand All @@ -125,11 +119,14 @@ tasks:
required: false
outputs:
iterator: directory_iterator

load_classifier:
plugin: dioptra_builtins.registry.mlflow.load_tensorflow_keras_classifier
inputs:
- name: string
- version: int
- name: name
type: string
required: true
- version: integer
outputs:
classifier: sequential

Expand All @@ -143,7 +140,7 @@ tasks:
log_results:
plugin: dioptra_builtins.tracking.mlflow.log_metrics
inputs:
metrics: eval_metric_results
- metrics: eval_metric_results

graph:

Expand Down
4 changes: 2 additions & 2 deletions examples/tensorflow-mnist-pixel-threshold/src/MLproject
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ entry_points:
seed: { type: float, default: -1 }
clip_values: { type: string, default: "[0,1]" }
command: >
PYTHONPATH=$DIOPTRA_PLUGIN_DIR run-experiment pt.yml
PYTHONPATH=$DIOPTRA_PLUGIN_DIR validate-experiment pt.yml && PYTHONPATH=$DIOPTRA_PLUGIN_DIR run-experiment pt.yml
-P data_dir={data_dir}
-P image_size={image_size}
-P adv_tar_name={adv_tar_name}
Expand All @@ -58,7 +58,7 @@ entry_points:
validation_split: { type: float, default: 0.2 }
seed: { type: float, default: -1 }
command: >
PYTHONPATH=$DIOPTRA_PLUGIN_DIR run-experiment train.yml
PYTHONPATH=$DIOPTRA_PLUGIN_DIR validate-experiment train.yml && PYTHONPATH=$DIOPTRA_PLUGIN_DIR run-experiment train.yml
-P training_dir={training_dir}
-P testing_dir={testing_dir}
-P image_size={image_size}
Expand Down
12 changes: 8 additions & 4 deletions examples/tensorflow-mnist-pixel-threshold/src/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ parameters:
adv_data_dir: adv_testing
distance_metrics_filename: distance_metrics.csv
model_name: mnist_le_net
model_version: "1"
model_version: 1
clip_values: [0, 1]
batch_size: 32
th: 1
Expand Down Expand Up @@ -85,7 +85,9 @@ tasks:
load_classifier:
plugin: dioptra_builtins.registry.art.load_wrapped_tensorflow_keras_classifier
inputs:
- name: string
- name: name
type: string
required: true
- version: integer
- classifier_kwargs: kwargs_null
outputs:
Expand All @@ -109,7 +111,7 @@ tasks:
type: distance_metrics_null
required: false
- name: rescale
type: float
type: number
required: false
- name: batch_size
type: integer
Expand All @@ -134,7 +136,9 @@ tasks:
- name: tarball_write_mode
type: string
required: false
- working_dir: path_string_null
- name: working_dir
type: path_string_null
required: false

upload_artifact_dataframe:
plugin: dioptra_builtins.artifacts.mlflow.upload_data_frame_artifact
Expand Down

0 comments on commit 23b2b38

Please sign in to comment.