Kadi-IAM commited on
Commit
9aaef6e
·
1 Parent(s): 252956d
Files changed (39) hide show
  1. A1_convert_mnist.py +120 -0
  2. A2_train_mnist_modified.py +427 -0
  3. DATA/ex-mnist/INPUTS/feature_distributions.png +0 -0
  4. DATA/ex-mnist/INPUTS/tfrecord/data_definition.json +0 -0
  5. DATA/ex-mnist/INPUTS/tfrecord/sample15665.tfrecord +0 -0
  6. DATA/ex-mnist/INPUTS/tfrecord/sample20785.tfrecord +0 -0
  7. DATA/ex-mnist/INPUTS/tfrecord/sample29579.tfrecord +0 -0
  8. DATA/ex-mnist/INPUTS/tfrecord/sample44196.tfrecord +0 -0
  9. DATA/ex-mnist/INPUTS/tfrecord/sample44853.tfrecord +0 -0
  10. DATA/ex-mnist/LOGS/2024-07-23_15-11-51_A1_convert_mnist.log +0 -0
  11. DATA/ex-mnist/LOGS/2024-07-23_15-32-16_A2_train_mnist_modified.log +157 -0
  12. DATA/ex-mnist/LOGS/2024-07-23_16-08-52_app.log +131 -0
  13. DATA/ex-mnist/LOGS/2024-07-23_16-11-14_app.log +131 -0
  14. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/cidsmodel.json +80 -0
  15. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/0000016/input_preprocess_weights.h5 +3 -0
  16. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/0000016/model_weights.h5 +3 -0
  17. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/0000016/output_preprocess_weights.h5 +3 -0
  18. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase00/input_preprocess_weights.h5 +3 -0
  19. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase00/model_weights.h5 +3 -0
  20. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase00/output_preprocess_weights.h5 +3 -0
  21. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase01/input_preprocess_weights.h5 +3 -0
  22. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase01/model_weights.h5 +3 -0
  23. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase01/output_preprocess_weights.h5 +3 -0
  24. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/hp.json +1 -0
  25. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/model.json +1030 -0
  26. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/plot/input_preprocess_model.png +0 -0
  27. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/plot/model.png +0 -0
  28. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/plot/output_preprocess_model.png +0 -0
  29. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/plot/postprocess_model.png +0 -0
  30. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/summary/train/events.out.tfevents.1721741561.mms-hgx-01.3272949.0.v2 +3 -0
  31. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/summary/train/events.out.tfevents.1721741652.mms-hgx-01.3272949.2.v2 +3 -0
  32. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/summary/validation/events.out.tfevents.1721741642.mms-hgx-01.3272949.1.v2 +3 -0
  33. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/summary/validation/events.out.tfevents.1721741685.mms-hgx-01.3272949.3.v2 +3 -0
  34. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/train_results_phase00.json +40 -0
  35. DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/train_results_phase01.json +135 -0
  36. DATA/ex-mnist/project_ex-mnist.json +0 -0
  37. README.md +6 -4
  38. app.py +200 -0
  39. requirements.txt +3 -0
A1_convert_mnist.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2022 Arnd Koeppe and the CIDS team
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ import os
16
+ from pathlib import Path
17
+
18
+ import tensorflow as tf
19
+ import tqdm
20
+
21
+ from cids.data import DataDefinition
22
+ from cids.data import DataWriter
23
+ from cids.data import Feature
24
+ from kadi_ai import KadiAIProject
25
+
26
+
27
+ ################################################################################
28
+ # Data paths
29
+
30
+ project_name = "ex-mnist"
31
+ project_dir = Path.cwd() / "DATA" / project_name
32
+ project = KadiAIProject(project_name, root=project_dir)
33
+
34
+ # Project creates an `input_dir` in the `project_dir`, which stores converted
35
+ # input data as tfrecords in a subdirectory `tfrecord`
36
+ tfrecord_dir = Path(project.input_dir) / "tfrecord"
37
+
38
+
39
+ ################################################################################
40
+ # Data definition
41
+
42
+ data_definition = DataDefinition(
43
+ Feature(
44
+ "image",
45
+ [None, 28, 28, 1],
46
+ data_format="NXYF",
47
+ dtype=tf.string,
48
+ decode_str_to=tf.float32,
49
+ ),
50
+ Feature(
51
+ "label", [None, 1], data_format="NF", dtype=tf.string, decode_str_to=tf.float32
52
+ ),
53
+ dtype=tf.float32,
54
+ )
55
+
56
+ project.data_definition = data_definition
57
+
58
+
59
+ ################################################################################
60
+ # Read data
61
+
62
+ (train_images, train_labels), (
63
+ test_images,
64
+ test_labels,
65
+ ) = tf.keras.datasets.mnist.load_data()
66
+
67
+ src_data = list(zip(train_images, train_labels))
68
+
69
+
70
+ ################################################################################
71
+ # Data processing
72
+
73
+
74
+ def read_and_process(src_sample):
75
+ """Read and process source data."""
76
+ # Do some preprocessing
77
+ image = src_sample[0]
78
+ image = (image - 127.5) / 127.5
79
+ # Pack into dictionary
80
+ sample = {}
81
+ sample["image"] = image
82
+ sample["label"] = src_sample[1]
83
+ return sample
84
+
85
+
86
+ ################################################################################
87
+ # Start processing
88
+
89
+ # Create a data converter object
90
+ data_writer = DataWriter(data_definition)
91
+
92
+ # Loop over all pairs of source files with a pretty progress bar
93
+ n = 0
94
+ for src_sample in tqdm.tqdm(
95
+ src_data,
96
+ total=len(src_data),
97
+ file=project.stream_to_logger(),
98
+ leave=True,
99
+ desc="Conversion",
100
+ unit="sources",
101
+ dynamic_ncols=True,
102
+ ):
103
+ # Process sample
104
+ sample = read_and_process(src_sample)
105
+ out_file = tfrecord_dir / f"sample{n:05d}.tfrecord"
106
+ # Write sample to file
107
+ try:
108
+ data_writer.write_example(out_file, sample)
109
+ except KeyError as e:
110
+ project.warn(f"Missing key {e.args[0]} in: {os.fspath(out_file)}")
111
+ continue
112
+ n += 1
113
+ project.log(f"Done processing: {os.fspath(out_file)}")
114
+
115
+ # Write the data definition and the features to a human-readable json file
116
+ # The json file can also be loaded directly later-on for training.
117
+ project.data_definition = data_definition
118
+ project.to_json(write_data_definition=True)
119
+
120
+ project.log("Done.")
A2_train_mnist_modified.py ADDED
@@ -0,0 +1,427 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2022 Arnd Koeppe and the CIDS team
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ import os
16
+
17
+ os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
18
+ os.environ["TF_FORCE_GPU_ALLOW_GROWTH"] = "true"
19
+
20
+ import cids
21
+
22
+ import numpy as np
23
+ import tensorflow as tf
24
+ import seaborn as sns
25
+
26
+ from pathlib import Path
27
+ from tensorflow.keras import layers as klayers
28
+ from cids.tensorflow import layers as clayers
29
+ from cids.tensorflow.tuner import SearchResults
30
+ from cids.statistics import metrics
31
+ from kadi_ai import KadiAIProject
32
+ from matplotlib import pyplot as plt
33
+ from kerastuner import HyperParameters
34
+
35
+ # Preamble
36
+ plt.style.use("seaborn-v0_8-paper") # seaborn-talk, seaborn-poster, seaborn-paper
37
+ plt.rcParams.update(
38
+ {
39
+ "font.family": "sans-serif",
40
+ "figure.dpi": 300,
41
+ "savefig.format": "png",
42
+ }
43
+ )
44
+
45
+
46
+ ################################################################################
47
+ # Controls
48
+
49
+ CHECK = True
50
+ SEARCH = False
51
+ USE_BEST_SEARCH_CONFIG = False
52
+ TRAIN = True
53
+ EVAL = True
54
+ PLOT = True
55
+ ANALYZE = False
56
+
57
+ TRAIN_CONTINUE = False
58
+
59
+
60
+ num_check_samples = 100
61
+ num_plot_samples = 20
62
+ num_principal_components = 3
63
+
64
+
65
+ ################################################################################
66
+ # Data paths
67
+
68
+ project_name = "ex-mnist"
69
+ project_dir = Path.cwd() / "DATA" / project_name
70
+ project = KadiAIProject(project_name, root=project_dir)
71
+
72
+ # Read paths
73
+ train_samples, valid_samples, test_samples = project.get_split_datasets(
74
+ shuffle=True, valid_split=0.15, test_split=0.15
75
+ )
76
+
77
+
78
+ ################################################################################
79
+ # Data definition
80
+
81
+ data_definition = project.data_definition
82
+ data_definition.input_features = ["image"]
83
+ data_definition.output_features = ["label"]
84
+
85
+
86
+ ################################################################################
87
+ # Neural network
88
+
89
+ # Model
90
+ def model_function(hp, data_definition):
91
+
92
+ # Hyper parameters
93
+ num_kernels = hp.Choice("num_kernels", [32, 64, 128, 256, 512], default=64)
94
+ dropout_rate = hp.Float("dropout", 0.0, 0.7, default=0.3) # not used
95
+
96
+ # Ref: https://github.com/AyaanZaveri/mnist/blob/main/MNIST_Number.ipynb
97
+ layers = []
98
+ layers.append(klayers.Conv2D(num_kernels, (3, 3), strides=(1, 1), padding="same"))
99
+ layers.append(klayers.ReLU())
100
+ layers.append(klayers.Conv2D(num_kernels, (3, 3), strides=(1, 1), padding="same"))
101
+ layers.append(klayers.ReLU())
102
+ # layers.append(klayers.Dropout(dropout_rate))
103
+ layers.append(klayers.MaxPooling2D(pool_size=(2, 2)))
104
+ layers.append(klayers.BatchNormalization())
105
+
106
+ layers.append(klayers.Conv2D(num_kernels*2, (3, 3), strides=(1, 1), padding="same"))
107
+ layers.append(klayers.ReLU())
108
+ layers.append(klayers.Conv2D(num_kernels*2, (3, 3), strides=(1, 1), padding="same"))
109
+ layers.append(klayers.ReLU())
110
+
111
+ layers.append(klayers.MaxPooling2D(pool_size=(2, 2)))
112
+ layers.append(klayers.BatchNormalization())
113
+
114
+ layers.append(klayers.Conv2D(num_kernels*4, (3, 3), strides=(1, 1), padding="same"))
115
+ layers.append(klayers.MaxPooling2D(pool_size=(2, 2)))
116
+
117
+ layers.append(klayers.Flatten())
118
+ layers.append(klayers.Dropout(dropout_rate))
119
+ layers.append(klayers.Dense(512))
120
+ layers.append(klayers.Dense(10, activation="softmax"))
121
+ return tf.keras.Sequential(layers)
122
+
123
+
124
+ # Set a model name
125
+ model_name = "mnist"
126
+ model_name += "--" + "--".join(
127
+ [
128
+ "+".join(list(data_definition.input_features)),
129
+ "+".join(list(data_definition.output_features)),
130
+ ]
131
+ )
132
+ model_name += "--onehot"
133
+
134
+
135
+ # Training schedule
136
+ def schedule_function(hp):
137
+ learning_rate = hp.Choice(
138
+ "learning_rate", [3e-3, 1e-3, 3e-4, 1e-4, 3e-5, 1e-5], default=1e-4
139
+ )
140
+ batch_size = 256 # divided by number of GPUs
141
+ schedule = {
142
+ "count": [1, 21],
143
+ "learning_rate": learning_rate,
144
+ "batch_size": batch_size,
145
+ }
146
+ return schedule
147
+
148
+
149
+ model = cids.CIDSModel.categorical_classification(
150
+ 10,
151
+ data_definition,
152
+ model_function,
153
+ name=model_name,
154
+ identifier="",
155
+ result_dir=project.result_dir,
156
+ )
157
+ model.encode_categorical = "outputs"
158
+ model.metrics.append("accuracy")
159
+ model.monitor = "val_accuracy"
160
+ model.online_normalize = False
161
+ model.data_reader.prefetch = "cache"
162
+
163
+
164
+ if CHECK:
165
+ if PLOT:
166
+ check_samples = model.read_tfrecords(
167
+ train_samples[:num_check_samples], disable_feature_merge=True
168
+ )
169
+ project.log("Plotting feature distributions.")
170
+ model.plot_feature_distribution(check_samples, project.input_dir)
171
+
172
+
173
+ if SEARCH:
174
+ project.log(">> Hyperparameters: searching...")
175
+ hp = model.search(
176
+ train_samples,
177
+ valid_samples,
178
+ schedule=schedule_function,
179
+ executions_per_trial=1,
180
+ max_epochs=3, # hyperband only
181
+ overwrite=False,
182
+ objective="val_mae",
183
+ method="hyperband",
184
+ # method="bayes",
185
+ num_trials=3,
186
+ # callbacks=[tf.keras.callbacks.EarlyStopping(patience=5)],
187
+ )
188
+ if PLOT:
189
+ search_results = SearchResults(model)
190
+ search_results.plot_hyperparameter_search()
191
+ model.identifier = "best"
192
+ project.log(">> Hyperparameters: search complete.")
193
+ elif USE_BEST_SEARCH_CONFIG:
194
+ try:
195
+ search_results = SearchResults(model)
196
+ hps = search_results.get_best_hyperparameters(print="best")
197
+ hp = hps[0]
198
+ model.identifier = "best"
199
+ project.log(">> Hyperparameters: loaded from previous search.")
200
+ except (FileNotFoundError, PermissionError) as e:
201
+ project.log(">> Hyperparameters: " + str(e))
202
+ project.log(">> Hyperparameters: No search found. Defaults loaded.")
203
+ hp = HyperParameters()
204
+ model.identifier = "default"
205
+ else:
206
+ project.log(">> Hyperparameters: Defaults loaded.")
207
+ hp = HyperParameters()
208
+ model.identifier = "default"
209
+
210
+
211
+ if TRAIN:
212
+ project.log(">> Training...")
213
+ if TRAIN_CONTINUE:
214
+ project.log(">> ...continuing from last...")
215
+ checkpoint = "last"
216
+ else:
217
+ project.log(">> ...starting new...")
218
+ checkpoint = None
219
+ model.VERBOSITY = 2
220
+ model.train(
221
+ train_samples,
222
+ valid_samples,
223
+ schedule=schedule_function,
224
+ checkpoint=checkpoint,
225
+ hp=hp,
226
+ )
227
+ # save hp
228
+ import json
229
+ hp_path = os.path.join(model.model_dir, "hp.json")
230
+ with open(hp_path, "w") as f:
231
+ json.dump(model._hp.get_config(), f)
232
+ print(model.model_dir)
233
+ print(model._hp)
234
+ print(model._hp.values)
235
+ print(model._checkpoint_dir)
236
+ print(model.model_dir)
237
+ exit()
238
+ project.log(">> Training complete.")
239
+
240
+ if EVAL:
241
+ project.log(">> Evaluating...")
242
+ project.log(">>> Metrics...")
243
+ # Compute predictions
244
+ # test_loss = model.eval_data(
245
+ # test_samples, batch_size=4, checkpoint="last", hp=hp, submodels="generator")
246
+ X, Y, Y_ = model.infer_data(
247
+ test_samples,
248
+ batch_size=4,
249
+ checkpoint="last",
250
+ hp=hp,
251
+ )
252
+ test_result_file = Path(model.base_model_dir, "test_results.npz")
253
+ np.savez(test_result_file, X=X, Y=Y, Y_=Y_)
254
+ # Evaluate metrics
255
+ total_metrics = {}
256
+ total_metrics["mae"] = metrics.mean_absolute_error(Y, Y_)
257
+ total_metrics["mape"] = metrics.mean_absolute_percentage_error(Y, Y_)
258
+ total_metrics["smape"] = metrics.symmetric_mean_absolute_percentage_error(Y, Y_)
259
+ total_metrics["rmse"] = metrics.root_mean_square_error(Y, Y_)
260
+ total_metrics["nrmse"] = metrics.normalized_root_mean_square_error(Y, Y_)
261
+ project.log("Total metrics")
262
+ for k, v in total_metrics.items():
263
+ project.log(f" {k}: {v}")
264
+ project.log("")
265
+
266
+ # Feature metrics
267
+ feature_metrics = {}
268
+ feature_metrics["mae"] = metrics.mean_absolute_error(Y, Y_, reduction_axes=(0,))
269
+ feature_metrics["mape"] = metrics.mean_absolute_percentage_error(
270
+ Y, Y_, reduction_axes=(0,)
271
+ )
272
+ feature_metrics["smape"] = metrics.symmetric_mean_absolute_percentage_error(
273
+ Y, Y_, reduction_axes=(0,)
274
+ )
275
+ feature_metrics["rmse"] = metrics.root_mean_square_error(Y, Y_, reduction_axes=(0,))
276
+ feature_metrics["nrmse"] = metrics.normalized_root_mean_square_error(
277
+ Y, Y_, reduction_axes=(0,)
278
+ )
279
+ project.log("Feature metrics")
280
+ for k, v in feature_metrics.items():
281
+ project.log(f" {k}: {v}")
282
+ project.log("")
283
+
284
+ # Sample metrics
285
+ sample_metrics = {}
286
+ sample_metrics["mae"] = metrics.mean_absolute_error(Y, Y_, reduction_axes=(1,))
287
+ sample_metrics["mape"] = metrics.mean_absolute_percentage_error(
288
+ Y, Y_, reduction_axes=(1,)
289
+ )
290
+ sample_metrics["smape"] = metrics.symmetric_mean_absolute_percentage_error(
291
+ Y, Y_, reduction_axes=(1,)
292
+ )
293
+ sample_metrics["rmse"] = metrics.root_mean_square_error(Y, Y_, reduction_axes=(1,))
294
+ sample_metrics["nrmse"] = metrics.normalized_root_mean_square_error(
295
+ Y, Y_, reduction_axes=(1,)
296
+ )
297
+ project.log("Sample metrics:")
298
+ for k, v in sample_metrics.items():
299
+ project.log(f" {k}: {v}")
300
+ project.log("")
301
+
302
+ # Select worst, best, mean, median samples
303
+ error_metric = "mae"
304
+ sample_errors = sample_metrics[error_metric]
305
+ total_error = total_metrics[error_metric]
306
+ sorted_sample_ids = np.argsort(sample_errors)
307
+ sorted_sample_errors = sample_errors[sorted_sample_ids]
308
+ # nonconvergence_cutoff = 100000.0
309
+ # converged_sorted_sample_errors = sorted_sample_errors[
310
+ # sorted_sample_errors < nonconvergence_cutoff
311
+ # ]
312
+ # converged_sorted_sample_ids = sorted_sample_ids[
313
+ # sorted_sample_errors < nonconvergence_cutoff
314
+ # ]
315
+ converged_sorted_sample_ids = sorted_sample_ids
316
+ converged_sorted_sample_errors = sorted_sample_errors
317
+ best_sample_id = converged_sorted_sample_ids[0]
318
+ worst_sample_id = converged_sorted_sample_ids[-1]
319
+ median_sample_id = converged_sorted_sample_ids[
320
+ len(converged_sorted_sample_ids) // 2
321
+ ]
322
+ perc25_sample_id = converged_sorted_sample_ids[
323
+ len(converged_sorted_sample_ids) * 1 // 4
324
+ ]
325
+ perc75_sample_id = converged_sorted_sample_ids[
326
+ len(converged_sorted_sample_ids) * 3 // 4
327
+ ]
328
+ mean_sample_id = np.argmin(
329
+ np.abs(sample_errors - np.mean(converged_sorted_sample_errors))
330
+ )
331
+ project.log(f"{project_name}: Sample quality: sample {error_metric}")
332
+ project.log(
333
+ f"{project_name}:\n"
334
+ + f" mean: {sample_errors[mean_sample_id]}"
335
+ + f" ({test_samples[mean_sample_id]})\n"
336
+ + f" best: {sample_errors[best_sample_id]}"
337
+ + f" ({test_samples[best_sample_id]})\n"
338
+ + f" worst: {sample_errors[worst_sample_id]}"
339
+ + f" ({test_samples[worst_sample_id]})\n"
340
+ + f" median: {sample_errors[median_sample_id]}"
341
+ + f" ({test_samples[median_sample_id]})\n"
342
+ + f" perc25: {sample_errors[perc25_sample_id]}"
343
+ + f" ({test_samples[perc25_sample_id]})\n"
344
+ + f" perc75: {sample_errors[perc75_sample_id]}"
345
+ + f" ({test_samples[perc75_sample_id]})\n"
346
+ )
347
+
348
+ # Plot
349
+ if PLOT:
350
+ project.log(">> Plotting results...")
351
+ test_result_file = Path(model.base_model_dir, "test_results.npz")
352
+ test_results = np.load(test_result_file)
353
+ X = test_results["X"][:num_plot_samples]
354
+ Y = test_results["Y"][:num_plot_samples]
355
+ Y_ = test_results["Y_"][:num_plot_samples]
356
+ # Plot individual samples
357
+ project.log(">>> Plotting individual samples")
358
+ for i, (x, y, y_) in enumerate(zip(X, Y, Y_)):
359
+ image = np.squeeze(x)
360
+ label = np.argmax(y, axis=-1)
361
+ prediction = np.argmax(y_, axis=-1)
362
+ # Draw
363
+ fig = plt.figure(figsize=(4, 3))
364
+ plt.imshow(image, cmap=sns.color_palette("mako_r", as_cmap=True))
365
+ plt.axis("off")
366
+ fig.suptitle(
367
+ f"label = {label:d}, prediction = {prediction:d} ({y_[prediction]})"
368
+ )
369
+ fig.tight_layout()
370
+ # Save and close
371
+ plot_file = os.path.join(
372
+ model.plot_dir, f"best_to_worst_{i:05d}_label={label:d}"
373
+ )
374
+ plt.savefig(plot_file)
375
+ plt.close()
376
+
377
+ # Explain
378
+ if ANALYZE:
379
+ analze_samples = test_samples[:10]
380
+ X, Y = model.read_tfrecords(test_samples[:num_plot_samples])
381
+ # # PCA analysis
382
+ # Y_, C1, C2 = model.predict(X, return_states=True)
383
+ # for si in range(num_plot_samples):
384
+ # # Compute PCA on single sample # TODO: pca over multiple samples?
385
+ # cov = np.dot(C1[si, ...].T, C1[si, ...])
386
+ # u, s, v = np.linalg.svd(cov, compute_uv=True)
387
+ # pc_axes = np.dot(C1[si, ...], u[:, :num_principal_components])
388
+ # # Plot loading and relaxation
389
+ # fig, axes = plt.subplots(3, 1, sharex=True, figsize=(7, 6),
390
+ # gridspec_kw={"height_ratios": [0.5, 1, 1]})
391
+ # plt.sca(axes[0])
392
+ # plt.plot(X[si, :, 0], "C0", label="strain")
393
+ # plt.ylabel("strain [-]")
394
+ # plt.sca(axes[1])
395
+ # plt.plot(Y[si, :, 1], "C2", label="strain_plastic_ref")
396
+ # plt.plot(Y_[si, :, 1], "C2", linestyle="dashed",
397
+ # label="strain_plastic")
398
+ # for pc in range(num_principal_components):
399
+ # plt.plot(pc_axes[:, pc], "C{:d}".format(3 + pc),
400
+ # linestyle="dotted", label="state{:d}".format(pc))
401
+ # plt.ylabel("history [-]")
402
+ # plt.sca(axes[2])
403
+ # plt.plot(Y[si, :, 0], "C1", label="stress_ref")
404
+ # plt.plot(Y_[si, :, 0], "C1", linestyle="dashed", label="stress")
405
+ # plt.ylabel("stress [-]")
406
+ # plt.xlabel("increments [-]")
407
+ # fig.legend(loc="upper center", ncol=4)
408
+ # plt.tight_layout()
409
+ # plt.draw()
410
+ # plt.savefig(os.path.join(model.plot_dir, "pca_{:06d}".format(si)))
411
+ # plt.close()
412
+ # Local response propagation
413
+ analysis = model.analyze(
414
+ X[:num_plot_samples, ...],
415
+ method="lrp.epsilon",
416
+ neuron_selection_mode="all",
417
+ # neuron_selection=0,
418
+ plot=True,
419
+ checkpoint="last",
420
+ )
421
+ project.log(">> Evaluation complete.")
422
+
423
+
424
+ ################################################################################
425
+ # Finished
426
+
427
+ project.log("done")
DATA/ex-mnist/INPUTS/feature_distributions.png ADDED
DATA/ex-mnist/INPUTS/tfrecord/data_definition.json ADDED
The diff for this file is too large to render. See raw diff
 
DATA/ex-mnist/INPUTS/tfrecord/sample15665.tfrecord ADDED
Binary file (3.24 kB). View file
 
DATA/ex-mnist/INPUTS/tfrecord/sample20785.tfrecord ADDED
Binary file (3.24 kB). View file
 
DATA/ex-mnist/INPUTS/tfrecord/sample29579.tfrecord ADDED
Binary file (3.24 kB). View file
 
DATA/ex-mnist/INPUTS/tfrecord/sample44196.tfrecord ADDED
Binary file (3.24 kB). View file
 
DATA/ex-mnist/INPUTS/tfrecord/sample44853.tfrecord ADDED
Binary file (3.24 kB). View file
 
DATA/ex-mnist/LOGS/2024-07-23_15-11-51_A1_convert_mnist.log ADDED
The diff for this file is too large to render. See raw diff
 
DATA/ex-mnist/LOGS/2024-07-23_15-32-16_A2_train_mnist_modified.log ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [2024-07-23 15:32:16,573)](INFO)KadiAIProject: Logging to /mnt/data2/yinghanz/codes/frameworks/test/cids/DATA/ex-mnist/LOGS/2024-07-23_15-32-16_A2_train_mnist_mine.log
2
+ [2024-07-23 15:32:16,575)](INFO)KadiAIProject: Setting seeds to: ex-mnist
3
+ [2024-07-23 15:32:16,578)](INFO)KadiAIProject: Loading from /mnt/data2/yinghanz/codes/frameworks/test/cids/DATA/ex-mnist/project_ex-mnist.json
4
+ [2024-07-23 15:32:19,552)](INFO)KadiAIProject: Git commit: 143d0296
5
+ [2024-07-23 15:32:33,830)](INFO)KadiAIProject: Reusing dataset split from previous run. Change project name or set enforce_new_split=True for new split.
6
+ [2024-07-23 15:32:38,183)](INFO)CIDSModelTF: Single CPU found. Using one device distribution.
7
+ [2024-07-23 15:32:38,185)](INFO)DataReader: (test) Estimated sample size: 0.00309086 MB.
8
+ [2024-07-23 15:32:38,186)](INFO)DataReader: (test) buffer_size set to maximum number of samples (100).
9
+ [2024-07-23 15:32:38,804)](INFO)KadiAIProject: Plotting feature distributions.
10
+ [2024-07-23 15:32:40,004)](INFO)KadiAIProject: >> Hyperparameters: Defaults loaded.
11
+ [2024-07-23 15:32:40,005)](INFO)KadiAIProject: >> Training...
12
+ [2024-07-23 15:32:40,006)](INFO)KadiAIProject: >> ...starting new...
13
+ [2024-07-23 15:32:40,007)](INFO)CIDSModelTF: Starting training schedule.
14
+ [2024-07-23 15:32:40,008)](INFO)CIDSModelTF: Starting training phase 0.
15
+ [2024-07-23 15:32:40,161)](INFO)CIDSModelTF: No checkpoint loaded.
16
+ [2024-07-23 15:32:40,196)](WARNING)CIDSModelTF: Clearing non-empty model directory.
17
+ [2024-07-23 15:32:40,199)](INFO)CIDSModelTF: Model Summary: mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10
18
+ [2024-07-23 15:32:40,200)](INFO)CIDSModelTF: Model: "InputPreprocess"
19
+ [2024-07-23 15:32:40,201)](INFO)CIDSModelTF: _________________________________________________________________
20
+ [2024-07-23 15:32:40,201)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
21
+ [2024-07-23 15:32:40,202)](INFO)CIDSModelTF: =================================================================
22
+ [2024-07-23 15:32:40,202)](INFO)CIDSModelTF: input_1 (InputLayer) [(None, 28, 28, 1)] 0
23
+ [2024-07-23 15:32:40,203)](INFO)CIDSModelTF:
24
+ [2024-07-23 15:32:40,203)](INFO)CIDSModelTF: tf.identity (TFOpLambda) (None, 28, 28, 1) 0
25
+ [2024-07-23 15:32:40,204)](INFO)CIDSModelTF:
26
+ [2024-07-23 15:32:40,204)](INFO)CIDSModelTF: tf.cast (TFOpLambda) (None, 28, 28, 1) 0
27
+ [2024-07-23 15:32:40,205)](INFO)CIDSModelTF:
28
+ [2024-07-23 15:32:40,205)](INFO)CIDSModelTF: =================================================================
29
+ [2024-07-23 15:32:40,205)](INFO)CIDSModelTF: Total params: 0
30
+ [2024-07-23 15:32:40,206)](INFO)CIDSModelTF: Trainable params: 0
31
+ [2024-07-23 15:32:40,206)](INFO)CIDSModelTF: Non-trainable params: 0
32
+ [2024-07-23 15:32:40,207)](INFO)CIDSModelTF: _________________________________________________________________
33
+ [2024-07-23 15:32:40,207)](INFO)CIDSModelTF: Model: "OutputPreprocess"
34
+ [2024-07-23 15:32:40,208)](INFO)CIDSModelTF: _________________________________________________________________
35
+ [2024-07-23 15:32:40,208)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
36
+ [2024-07-23 15:32:40,209)](INFO)CIDSModelTF: =================================================================
37
+ [2024-07-23 15:32:40,209)](INFO)CIDSModelTF: input_2 (InputLayer) [(None, 1)] 0
38
+ [2024-07-23 15:32:40,210)](INFO)CIDSModelTF:
39
+ [2024-07-23 15:32:40,214)](INFO)CIDSModelTF: tf.identity_1 (TFOpLambda) (None, 1) 0
40
+ [2024-07-23 15:32:40,214)](INFO)CIDSModelTF:
41
+ [2024-07-23 15:32:40,215)](INFO)CIDSModelTF: tf.__operators__.getitem (S (None,) 0
42
+ [2024-07-23 15:32:40,215)](INFO)CIDSModelTF: licingOpLambda)
43
+ [2024-07-23 15:32:40,216)](INFO)CIDSModelTF:
44
+ [2024-07-23 15:32:40,216)](INFO)CIDSModelTF: tf.cast_1 (TFOpLambda) (None,) 0
45
+ [2024-07-23 15:32:40,216)](INFO)CIDSModelTF:
46
+ [2024-07-23 15:32:40,217)](INFO)CIDSModelTF: tf.one_hot (TFOpLambda) (None, 10) 0
47
+ [2024-07-23 15:32:40,217)](INFO)CIDSModelTF:
48
+ [2024-07-23 15:32:40,218)](INFO)CIDSModelTF: tf.cast_2 (TFOpLambda) (None, 10) 0
49
+ [2024-07-23 15:32:40,218)](INFO)CIDSModelTF:
50
+ [2024-07-23 15:32:40,219)](INFO)CIDSModelTF: =================================================================
51
+ [2024-07-23 15:32:40,219)](INFO)CIDSModelTF: Total params: 0
52
+ [2024-07-23 15:32:40,219)](INFO)CIDSModelTF: Trainable params: 0
53
+ [2024-07-23 15:32:40,220)](INFO)CIDSModelTF: Non-trainable params: 0
54
+ [2024-07-23 15:32:40,220)](INFO)CIDSModelTF: _________________________________________________________________
55
+ [2024-07-23 15:32:40,221)](INFO)CIDSModelTF: Model: "Core"
56
+ [2024-07-23 15:32:40,221)](INFO)CIDSModelTF: _________________________________________________________________
57
+ [2024-07-23 15:32:40,221)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
58
+ [2024-07-23 15:32:40,222)](INFO)CIDSModelTF: =================================================================
59
+ [2024-07-23 15:32:40,222)](INFO)CIDSModelTF: input_3 (InputLayer) [(None, 28, 28, 1)] 0
60
+ [2024-07-23 15:32:40,223)](INFO)CIDSModelTF:
61
+ [2024-07-23 15:32:40,223)](INFO)CIDSModelTF: conv2d (Conv2D) (None, 28, 28, 64) 640
62
+ [2024-07-23 15:32:40,224)](INFO)CIDSModelTF:
63
+ [2024-07-23 15:32:40,224)](INFO)CIDSModelTF: re_lu (ReLU) (None, 28, 28, 64) 0
64
+ [2024-07-23 15:32:40,225)](INFO)CIDSModelTF:
65
+ [2024-07-23 15:32:40,225)](INFO)CIDSModelTF: conv2d_1 (Conv2D) (None, 28, 28, 64) 36928
66
+ [2024-07-23 15:32:40,225)](INFO)CIDSModelTF:
67
+ [2024-07-23 15:32:40,226)](INFO)CIDSModelTF: re_lu_1 (ReLU) (None, 28, 28, 64) 0
68
+ [2024-07-23 15:32:40,226)](INFO)CIDSModelTF:
69
+ [2024-07-23 15:32:40,227)](INFO)CIDSModelTF: max_pooling2d (MaxPooling2D (None, 14, 14, 64) 0
70
+ [2024-07-23 15:32:40,227)](INFO)CIDSModelTF: )
71
+ [2024-07-23 15:32:40,228)](INFO)CIDSModelTF:
72
+ [2024-07-23 15:32:40,228)](INFO)CIDSModelTF: batch_normalization (BatchN (None, 14, 14, 64) 256
73
+ [2024-07-23 15:32:40,228)](INFO)CIDSModelTF: ormalization)
74
+ [2024-07-23 15:32:40,229)](INFO)CIDSModelTF:
75
+ [2024-07-23 15:32:40,229)](INFO)CIDSModelTF: conv2d_2 (Conv2D) (None, 14, 14, 128) 73856
76
+ [2024-07-23 15:32:40,230)](INFO)CIDSModelTF:
77
+ [2024-07-23 15:32:40,230)](INFO)CIDSModelTF: re_lu_2 (ReLU) (None, 14, 14, 128) 0
78
+ [2024-07-23 15:32:40,231)](INFO)CIDSModelTF:
79
+ [2024-07-23 15:32:40,231)](INFO)CIDSModelTF: conv2d_3 (Conv2D) (None, 14, 14, 128) 147584
80
+ [2024-07-23 15:32:40,232)](INFO)CIDSModelTF:
81
+ [2024-07-23 15:32:40,232)](INFO)CIDSModelTF: re_lu_3 (ReLU) (None, 14, 14, 128) 0
82
+ [2024-07-23 15:32:40,233)](INFO)CIDSModelTF:
83
+ [2024-07-23 15:32:40,233)](INFO)CIDSModelTF: max_pooling2d_1 (MaxPooling (None, 7, 7, 128) 0
84
+ [2024-07-23 15:32:40,234)](INFO)CIDSModelTF: 2D)
85
+ [2024-07-23 15:32:40,234)](INFO)CIDSModelTF:
86
+ [2024-07-23 15:32:40,235)](INFO)CIDSModelTF: batch_normalization_1 (Batc (None, 7, 7, 128) 512
87
+ [2024-07-23 15:32:40,235)](INFO)CIDSModelTF: hNormalization)
88
+ [2024-07-23 15:32:40,236)](INFO)CIDSModelTF:
89
+ [2024-07-23 15:32:40,236)](INFO)CIDSModelTF: conv2d_4 (Conv2D) (None, 7, 7, 256) 295168
90
+ [2024-07-23 15:32:40,236)](INFO)CIDSModelTF:
91
+ [2024-07-23 15:32:40,237)](INFO)CIDSModelTF: max_pooling2d_2 (MaxPooling (None, 3, 3, 256) 0
92
+ [2024-07-23 15:32:40,237)](INFO)CIDSModelTF: 2D)
93
+ [2024-07-23 15:32:40,238)](INFO)CIDSModelTF:
94
+ [2024-07-23 15:32:40,238)](INFO)CIDSModelTF: flatten (Flatten) (None, 2304) 0
95
+ [2024-07-23 15:32:40,239)](INFO)CIDSModelTF:
96
+ [2024-07-23 15:32:40,239)](INFO)CIDSModelTF: dropout (Dropout) (None, 2304) 0
97
+ [2024-07-23 15:32:40,240)](INFO)CIDSModelTF:
98
+ [2024-07-23 15:32:40,240)](INFO)CIDSModelTF: dense (Dense) (None, 512) 1180160
99
+ [2024-07-23 15:32:40,241)](INFO)CIDSModelTF:
100
+ [2024-07-23 15:32:40,242)](INFO)CIDSModelTF: dense_1 (Dense) (None, 10) 5130
101
+ [2024-07-23 15:32:40,242)](INFO)CIDSModelTF:
102
+ [2024-07-23 15:32:40,243)](INFO)CIDSModelTF: =================================================================
103
+ [2024-07-23 15:32:40,244)](INFO)CIDSModelTF: Total params: 1,740,234
104
+ [2024-07-23 15:32:40,244)](INFO)CIDSModelTF: Trainable params: 1,739,850
105
+ [2024-07-23 15:32:40,245)](INFO)CIDSModelTF: Non-trainable params: 384
106
+ [2024-07-23 15:32:40,245)](INFO)CIDSModelTF: _________________________________________________________________
107
+ [2024-07-23 15:32:40,246)](INFO)CIDSModelTF: Model: "Postprocess"
108
+ [2024-07-23 15:32:40,246)](INFO)CIDSModelTF: _________________________________________________________________
109
+ [2024-07-23 15:32:40,247)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
110
+ [2024-07-23 15:32:40,247)](INFO)CIDSModelTF: =================================================================
111
+ [2024-07-23 15:32:40,248)](INFO)CIDSModelTF: input_5 (InputLayer) [(None, 10)] 0
112
+ [2024-07-23 15:32:40,248)](INFO)CIDSModelTF:
113
+ [2024-07-23 15:32:40,249)](INFO)CIDSModelTF: tf.math.argmax (TFOpLambda) (None,) 0
114
+ [2024-07-23 15:32:40,250)](INFO)CIDSModelTF:
115
+ [2024-07-23 15:32:40,250)](INFO)CIDSModelTF: tf.expand_dims (TFOpLambda) (None, 1) 0
116
+ [2024-07-23 15:32:40,251)](INFO)CIDSModelTF:
117
+ [2024-07-23 15:32:40,252)](INFO)CIDSModelTF: =================================================================
118
+ [2024-07-23 15:32:40,252)](INFO)CIDSModelTF: Total params: 0
119
+ [2024-07-23 15:32:40,253)](INFO)CIDSModelTF: Trainable params: 0
120
+ [2024-07-23 15:32:40,254)](INFO)CIDSModelTF: Non-trainable params: 0
121
+ [2024-07-23 15:32:40,254)](INFO)CIDSModelTF: _________________________________________________________________
122
+ [2024-07-23 15:32:40,256)](INFO)CIDSModelTF: Estimated memory (Core model): 0.349000 GBytes
123
+ [2024-07-23 15:32:40,257)](INFO)CIDSModelTF: Estimated memory (Input preprocess model): 0.002000 GBytes
124
+ [2024-07-23 15:32:40,258)](INFO)CIDSModelTF: Estimated memory (Output preprocess model): 0.000000 GBytes
125
+ [2024-07-23 15:32:40,258)](INFO)CIDSModelTF: Estimated memory (Postprocess model): 0.000000 GBytes
126
+ [2024-07-23 15:32:40,259)](INFO)CIDSModelTF: Plotting models.
127
+ [2024-07-23 15:32:40,465)](INFO)DataReader: (train) Caching dataset. Disable by setting model.data_reader.prefetch = True. Currently set to: "cache".
128
+ [2024-07-23 15:32:41,136)](INFO)DataReader: (valid) Caching dataset. Disable by setting model.data_reader.prefetch = True. Currently set to: "cache".
129
+ [2024-07-23 15:32:41,388)](INFO)CIDSModelTF: Training phase 0: 0%| | 0/1 [00:00<?, ?it/s]
130
+ [2024-07-23 15:34:12,048)](INFO)CIDSModelTF: Training phase 0: 100%|##########| 1/1 [01:30<00:00, 90.66s/it, epoch=0001, accuracy=0.902, loss=0.317, val_accuracy=0.116, val_loss=3.11]
131
+ [2024-07-23 15:34:12,355)](INFO)CIDSModelTF: Training phase 0: 100%|##########| 1/1 [01:30<00:00, 90.97s/it, epoch=0001, accuracy=0.902, loss=0.317, val_accuracy=0.116, val_loss=3.11]
132
+ [2024-07-23 15:34:12,380)](INFO)CIDSModelTF: Training phase finished successfully.
133
+ [2024-07-23 15:34:12,452)](INFO)CIDSModelTF: Starting training phase 1.
134
+ [2024-07-23 15:34:12,526)](INFO)CIDSModelTF: Training phase 1: 0%| | 0/20 [00:00<?, ?it/s]
135
+ [2024-07-23 15:34:46,689)](INFO)CIDSModelTF: Training phase 1: 5%|5 | 1/20 [00:34<10:49, 34.16s/it, epoch=0002, accuracy=0.978, loss=0.0697, val_accuracy=0.147, val_loss=3.06]
136
+ [2024-07-23 15:35:21,365)](INFO)CIDSModelTF: Training phase 1: 10%|# | 2/20 [01:08<10:20, 34.46s/it, epoch=0003, accuracy=0.984, loss=0.0504, val_accuracy=0.857, val_loss=0.4]
137
+ [2024-07-23 15:35:55,239)](INFO)CIDSModelTF: Training phase 1: 15%|#5 | 3/20 [01:42<09:41, 34.19s/it, epoch=0004, accuracy=0.991, loss=0.0301, val_accuracy=0.982, val_loss=0.0621]
138
+ [2024-07-23 15:36:29,156)](INFO)CIDSModelTF: Training phase 1: 20%|## | 4/20 [02:16<09:05, 34.08s/it, epoch=0005, accuracy=0.992, loss=0.0236, val_accuracy=0.987, val_loss=0.0386]
139
+ [2024-07-23 15:37:02,554)](INFO)CIDSModelTF: Training phase 1: 25%|##5 | 5/20 [02:50<08:27, 33.84s/it, epoch=0006, accuracy=0.996, loss=0.0154, val_accuracy=0.987, val_loss=0.0368]
140
+ [2024-07-23 15:37:35,633)](INFO)CIDSModelTF: Training phase 1: 30%|### | 6/20 [03:23<07:50, 33.58s/it, epoch=0007, accuracy=0.997, loss=0.0115, val_accuracy=0.988, val_loss=0.0381]
141
+ [2024-07-23 15:38:08,646)](INFO)CIDSModelTF: Training phase 1: 35%|###5 | 7/20 [03:56<07:14, 33.39s/it, epoch=0008, accuracy=0.998, loss=0.0086, val_accuracy=0.99, val_loss=0.0331]
142
+ [2024-07-23 15:38:42,378)](INFO)CIDSModelTF: Training phase 1: 40%|#### | 8/20 [04:29<06:42, 33.50s/it, epoch=0009, accuracy=0.998, loss=0.00658, val_accuracy=0.99, val_loss=0.0356]
143
+ [2024-07-23 15:39:17,075)](INFO)CIDSModelTF: Training phase 1: 45%|####5 | 9/20 [05:04<06:12, 33.88s/it, epoch=0010, accuracy=0.998, loss=0.00761, val_accuracy=0.99, val_loss=0.0328]
144
+ [2024-07-23 15:39:51,655)](INFO)CIDSModelTF: Training phase 1: 50%|##### | 10/20 [05:39<05:40, 34.09s/it, epoch=0011, accuracy=0.998, loss=0.00537, val_accuracy=0.99, val_loss=0.034]
145
+ [2024-07-23 15:40:26,613)](INFO)CIDSModelTF: Training phase 1: 55%|#####5 | 11/20 [06:14<05:09, 34.36s/it, epoch=0012, accuracy=0.999, loss=0.00374, val_accuracy=0.99, val_loss=0.0339]
146
+ [2024-07-23 15:41:01,613)](INFO)CIDSModelTF: Training phase 1: 60%|###### | 12/20 [06:49<04:36, 34.55s/it, epoch=0013, accuracy=0.999, loss=0.00393, val_accuracy=0.989, val_loss=0.0366]
147
+ [2024-07-23 15:41:36,608)](INFO)CIDSModelTF: Training phase 1: 65%|######5 | 13/20 [07:24<04:02, 34.69s/it, epoch=0014, accuracy=0.999, loss=0.00374, val_accuracy=0.988, val_loss=0.039]
148
+ [2024-07-23 15:42:11,805)](INFO)CIDSModelTF: Training phase 1: 70%|####### | 14/20 [07:59<03:29, 34.84s/it, epoch=0015, accuracy=0.999, loss=0.00329, val_accuracy=0.988, val_loss=0.0427]
149
+ [2024-07-23 15:42:47,331)](INFO)CIDSModelTF: Training phase 1: 75%|#######5 | 15/20 [08:34<02:55, 35.05s/it, epoch=0016, accuracy=0.998, loss=0.0047, val_accuracy=0.992, val_loss=0.0312]
150
+ [2024-07-23 15:43:22,394)](INFO)CIDSModelTF: Training phase 1: 80%|######## | 16/20 [09:09<02:20, 35.05s/it, epoch=0017, accuracy=0.999, loss=0.00354, val_accuracy=0.99, val_loss=0.0359]
151
+ [2024-07-23 15:43:57,448)](INFO)CIDSModelTF: Training phase 1: 85%|########5 | 17/20 [09:44<01:45, 35.05s/it, epoch=0018, accuracy=0.999, loss=0.00273, val_accuracy=0.99, val_loss=0.0379]
152
+ [2024-07-23 15:44:32,451)](INFO)CIDSModelTF: Training phase 1: 90%|######### | 18/20 [10:19<01:10, 35.04s/it, epoch=0019, accuracy=0.999, loss=0.00416, val_accuracy=0.99, val_loss=0.0399]
153
+ [2024-07-23 15:45:05,360)](INFO)CIDSModelTF: Training phase 1: 95%|#########5| 19/20 [10:52<00:34, 34.40s/it, epoch=0020, accuracy=0.998, loss=0.00527, val_accuracy=0.99, val_loss=0.0445]
154
+ [2024-07-23 15:45:40,337)](INFO)CIDSModelTF: Training phase 1: 100%|##########| 20/20 [11:27<00:00, 34.57s/it, epoch=0021, accuracy=0.998, loss=0.00522, val_accuracy=0.989, val_loss=0.041]
155
+ [2024-07-23 15:45:40,551)](INFO)CIDSModelTF: Training phase 1: 100%|##########| 20/20 [11:28<00:00, 34.40s/it, epoch=0021, accuracy=0.998, loss=0.00522, val_accuracy=0.989, val_loss=0.041]
156
+ [2024-07-23 15:45:40,588)](INFO)CIDSModelTF: Training phase finished successfully.
157
+ [2024-07-23 15:45:40,675)](INFO)CIDSModelTF: Training schedule finished.
DATA/ex-mnist/LOGS/2024-07-23_16-08-52_app.log ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [2024-07-23 16:08:52,656)](INFO)KadiAIProject: Logging to /mnt/data2/yinghanz/codes/frameworks/test/cids_gr_example/DATA/ex-mnist/LOGS/2024-07-23_16-08-52_app.log
2
+ [2024-07-23 16:08:52,658)](INFO)KadiAIProject: Setting seeds to: ex-mnist
3
+ [2024-07-23 16:08:52,661)](INFO)KadiAIProject: Loading from /mnt/data2/yinghanz/codes/frameworks/test/cids_gr_example/DATA/ex-mnist/project_ex-mnist.json
4
+ [2024-07-23 16:08:54,685)](INFO)KadiAIProject: Git commit: 143d0296
5
+ [2024-07-23 16:08:54,894)](INFO)CIDSModelTF: Single CPU found. Using one device distribution.
6
+ [2024-07-23 16:08:54,898)](INFO)KadiAIProject: >> Evaluating...
7
+ [2024-07-23 16:08:54,899)](INFO)KadiAIProject: >>> Metrics...
8
+ [2024-07-23 16:08:55,081)](WARNING)CIDSModelTF: Attempting to load checkpoint='last' but model.save_best_only = True. This will not load the final model state at the end of training but the last checkpoint that improved the model.monitor = 'val_accuracy'. Use checkpoint='last_phase' to get final state.
9
+ [2024-07-23 16:08:55,085)](INFO)CIDSModelTF: Continuing from epoch 16 (checkpoint 0000016).
10
+ [2024-07-23 16:08:55,186)](INFO)CIDSModelTF: Model Summary: mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10
11
+ [2024-07-23 16:08:55,187)](INFO)CIDSModelTF: Model: "InputPreprocess"
12
+ [2024-07-23 16:08:55,188)](INFO)CIDSModelTF: _________________________________________________________________
13
+ [2024-07-23 16:08:55,189)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
14
+ [2024-07-23 16:08:55,189)](INFO)CIDSModelTF: =================================================================
15
+ [2024-07-23 16:08:55,190)](INFO)CIDSModelTF: input_1 (InputLayer) [(None, 28, 28, 1)] 0
16
+ [2024-07-23 16:08:55,191)](INFO)CIDSModelTF:
17
+ [2024-07-23 16:08:55,192)](INFO)CIDSModelTF: tf.identity (TFOpLambda) (None, 28, 28, 1) 0
18
+ [2024-07-23 16:08:55,193)](INFO)CIDSModelTF:
19
+ [2024-07-23 16:08:55,193)](INFO)CIDSModelTF: tf.cast (TFOpLambda) (None, 28, 28, 1) 0
20
+ [2024-07-23 16:08:55,194)](INFO)CIDSModelTF:
21
+ [2024-07-23 16:08:55,195)](INFO)CIDSModelTF: =================================================================
22
+ [2024-07-23 16:08:55,195)](INFO)CIDSModelTF: Total params: 0
23
+ [2024-07-23 16:08:55,196)](INFO)CIDSModelTF: Trainable params: 0
24
+ [2024-07-23 16:08:55,197)](INFO)CIDSModelTF: Non-trainable params: 0
25
+ [2024-07-23 16:08:55,197)](INFO)CIDSModelTF: _________________________________________________________________
26
+ [2024-07-23 16:08:55,198)](INFO)CIDSModelTF: Model: "OutputPreprocess"
27
+ [2024-07-23 16:08:55,198)](INFO)CIDSModelTF: _________________________________________________________________
28
+ [2024-07-23 16:08:55,199)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
29
+ [2024-07-23 16:08:55,200)](INFO)CIDSModelTF: =================================================================
30
+ [2024-07-23 16:08:55,200)](INFO)CIDSModelTF: input_2 (InputLayer) [(None, 1)] 0
31
+ [2024-07-23 16:08:55,201)](INFO)CIDSModelTF:
32
+ [2024-07-23 16:08:55,201)](INFO)CIDSModelTF: tf.identity_1 (TFOpLambda) (None, 1) 0
33
+ [2024-07-23 16:08:55,202)](INFO)CIDSModelTF:
34
+ [2024-07-23 16:08:55,203)](INFO)CIDSModelTF: tf.__operators__.getitem (S (None,) 0
35
+ [2024-07-23 16:08:55,203)](INFO)CIDSModelTF: licingOpLambda)
36
+ [2024-07-23 16:08:55,204)](INFO)CIDSModelTF:
37
+ [2024-07-23 16:08:55,205)](INFO)CIDSModelTF: tf.cast_1 (TFOpLambda) (None,) 0
38
+ [2024-07-23 16:08:55,205)](INFO)CIDSModelTF:
39
+ [2024-07-23 16:08:55,206)](INFO)CIDSModelTF: tf.one_hot (TFOpLambda) (None, 10) 0
40
+ [2024-07-23 16:08:55,207)](INFO)CIDSModelTF:
41
+ [2024-07-23 16:08:55,207)](INFO)CIDSModelTF: tf.cast_2 (TFOpLambda) (None, 10) 0
42
+ [2024-07-23 16:08:55,208)](INFO)CIDSModelTF:
43
+ [2024-07-23 16:08:55,209)](INFO)CIDSModelTF: =================================================================
44
+ [2024-07-23 16:08:55,210)](INFO)CIDSModelTF: Total params: 0
45
+ [2024-07-23 16:08:55,210)](INFO)CIDSModelTF: Trainable params: 0
46
+ [2024-07-23 16:08:55,211)](INFO)CIDSModelTF: Non-trainable params: 0
47
+ [2024-07-23 16:08:55,212)](INFO)CIDSModelTF: _________________________________________________________________
48
+ [2024-07-23 16:08:55,213)](INFO)CIDSModelTF: Model: "Core"
49
+ [2024-07-23 16:08:55,213)](INFO)CIDSModelTF: _________________________________________________________________
50
+ [2024-07-23 16:08:55,214)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
51
+ [2024-07-23 16:08:55,215)](INFO)CIDSModelTF: =================================================================
52
+ [2024-07-23 16:08:55,216)](INFO)CIDSModelTF: input_3 (InputLayer) [(None, 28, 28, 1)] 0
53
+ [2024-07-23 16:08:55,217)](INFO)CIDSModelTF:
54
+ [2024-07-23 16:08:55,217)](INFO)CIDSModelTF: conv2d (Conv2D) (None, 28, 28, 64) 640
55
+ [2024-07-23 16:08:55,218)](INFO)CIDSModelTF:
56
+ [2024-07-23 16:08:55,219)](INFO)CIDSModelTF: re_lu (ReLU) (None, 28, 28, 64) 0
57
+ [2024-07-23 16:08:55,219)](INFO)CIDSModelTF:
58
+ [2024-07-23 16:08:55,220)](INFO)CIDSModelTF: conv2d_1 (Conv2D) (None, 28, 28, 64) 36928
59
+ [2024-07-23 16:08:55,221)](INFO)CIDSModelTF:
60
+ [2024-07-23 16:08:55,222)](INFO)CIDSModelTF: re_lu_1 (ReLU) (None, 28, 28, 64) 0
61
+ [2024-07-23 16:08:55,222)](INFO)CIDSModelTF:
62
+ [2024-07-23 16:08:55,223)](INFO)CIDSModelTF: max_pooling2d (MaxPooling2D (None, 14, 14, 64) 0
63
+ [2024-07-23 16:08:55,223)](INFO)CIDSModelTF: )
64
+ [2024-07-23 16:08:55,224)](INFO)CIDSModelTF:
65
+ [2024-07-23 16:08:55,225)](INFO)CIDSModelTF: batch_normalization (BatchN (None, 14, 14, 64) 256
66
+ [2024-07-23 16:08:55,225)](INFO)CIDSModelTF: ormalization)
67
+ [2024-07-23 16:08:55,226)](INFO)CIDSModelTF:
68
+ [2024-07-23 16:08:55,227)](INFO)CIDSModelTF: conv2d_2 (Conv2D) (None, 14, 14, 128) 73856
69
+ [2024-07-23 16:08:55,227)](INFO)CIDSModelTF:
70
+ [2024-07-23 16:08:55,228)](INFO)CIDSModelTF: re_lu_2 (ReLU) (None, 14, 14, 128) 0
71
+ [2024-07-23 16:08:55,229)](INFO)CIDSModelTF:
72
+ [2024-07-23 16:08:55,230)](INFO)CIDSModelTF: conv2d_3 (Conv2D) (None, 14, 14, 128) 147584
73
+ [2024-07-23 16:08:55,230)](INFO)CIDSModelTF:
74
+ [2024-07-23 16:08:55,231)](INFO)CIDSModelTF: re_lu_3 (ReLU) (None, 14, 14, 128) 0
75
+ [2024-07-23 16:08:55,231)](INFO)CIDSModelTF:
76
+ [2024-07-23 16:08:55,232)](INFO)CIDSModelTF: max_pooling2d_1 (MaxPooling (None, 7, 7, 128) 0
77
+ [2024-07-23 16:08:55,232)](INFO)CIDSModelTF: 2D)
78
+ [2024-07-23 16:08:55,233)](INFO)CIDSModelTF:
79
+ [2024-07-23 16:08:55,234)](INFO)CIDSModelTF: batch_normalization_1 (Batc (None, 7, 7, 128) 512
80
+ [2024-07-23 16:08:55,234)](INFO)CIDSModelTF: hNormalization)
81
+ [2024-07-23 16:08:55,235)](INFO)CIDSModelTF:
82
+ [2024-07-23 16:08:55,236)](INFO)CIDSModelTF: conv2d_4 (Conv2D) (None, 7, 7, 256) 295168
83
+ [2024-07-23 16:08:55,236)](INFO)CIDSModelTF:
84
+ [2024-07-23 16:08:55,237)](INFO)CIDSModelTF: max_pooling2d_2 (MaxPooling (None, 3, 3, 256) 0
85
+ [2024-07-23 16:08:55,237)](INFO)CIDSModelTF: 2D)
86
+ [2024-07-23 16:08:55,238)](INFO)CIDSModelTF:
87
+ [2024-07-23 16:08:55,239)](INFO)CIDSModelTF: flatten (Flatten) (None, 2304) 0
88
+ [2024-07-23 16:08:55,239)](INFO)CIDSModelTF:
89
+ [2024-07-23 16:08:55,240)](INFO)CIDSModelTF: dropout (Dropout) (None, 2304) 0
90
+ [2024-07-23 16:08:55,240)](INFO)CIDSModelTF:
91
+ [2024-07-23 16:08:55,241)](INFO)CIDSModelTF: dense (Dense) (None, 512) 1180160
92
+ [2024-07-23 16:08:55,242)](INFO)CIDSModelTF:
93
+ [2024-07-23 16:08:55,242)](INFO)CIDSModelTF: dense_1 (Dense) (None, 10) 5130
94
+ [2024-07-23 16:08:55,243)](INFO)CIDSModelTF:
95
+ [2024-07-23 16:08:55,243)](INFO)CIDSModelTF: =================================================================
96
+ [2024-07-23 16:08:55,245)](INFO)CIDSModelTF: Total params: 1,740,234
97
+ [2024-07-23 16:08:55,245)](INFO)CIDSModelTF: Trainable params: 1,739,850
98
+ [2024-07-23 16:08:55,246)](INFO)CIDSModelTF: Non-trainable params: 384
99
+ [2024-07-23 16:08:55,247)](INFO)CIDSModelTF: _________________________________________________________________
100
+ [2024-07-23 16:08:55,247)](INFO)CIDSModelTF: Model: "Postprocess"
101
+ [2024-07-23 16:08:55,248)](INFO)CIDSModelTF: _________________________________________________________________
102
+ [2024-07-23 16:08:55,249)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
103
+ [2024-07-23 16:08:55,249)](INFO)CIDSModelTF: =================================================================
104
+ [2024-07-23 16:08:55,250)](INFO)CIDSModelTF: input_5 (InputLayer) [(None, 10)] 0
105
+ [2024-07-23 16:08:55,251)](INFO)CIDSModelTF:
106
+ [2024-07-23 16:08:55,252)](INFO)CIDSModelTF: tf.math.argmax (TFOpLambda) (None,) 0
107
+ [2024-07-23 16:08:55,252)](INFO)CIDSModelTF:
108
+ [2024-07-23 16:08:55,253)](INFO)CIDSModelTF: tf.expand_dims (TFOpLambda) (None, 1) 0
109
+ [2024-07-23 16:08:55,254)](INFO)CIDSModelTF:
110
+ [2024-07-23 16:08:55,254)](INFO)CIDSModelTF: =================================================================
111
+ [2024-07-23 16:08:55,255)](INFO)CIDSModelTF: Total params: 0
112
+ [2024-07-23 16:08:55,255)](INFO)CIDSModelTF: Trainable params: 0
113
+ [2024-07-23 16:08:55,256)](INFO)CIDSModelTF: Non-trainable params: 0
114
+ [2024-07-23 16:08:55,256)](INFO)CIDSModelTF: _________________________________________________________________
115
+ [2024-07-23 16:08:55,259)](INFO)CIDSModelTF: Estimated memory (Core model): 0.012000 GBytes
116
+ [2024-07-23 16:08:55,260)](INFO)CIDSModelTF: Estimated memory (Input preprocess model): 0.000000 GBytes
117
+ [2024-07-23 16:08:55,260)](INFO)CIDSModelTF: Estimated memory (Output preprocess model): 0.000000 GBytes
118
+ [2024-07-23 16:08:55,261)](INFO)CIDSModelTF: Estimated memory (Postprocess model): 0.000000 GBytes
119
+ [2024-07-23 16:08:55,263)](INFO)DataReader: (test) Estimated sample size: 0.00309086 MB.
120
+ [2024-07-23 16:08:55,264)](INFO)DataReader: (test) buffer_size set to maximum number of samples (1).
121
+ [2024-07-23 16:08:55,680)](INFO)DataReader: (test) Caching dataset. Disable by setting model.data_reader.prefetch = True. Currently set to: "cache".
122
+ [2024-07-23 16:08:55,684)](WARNING)DataReader: Batch size is larger than dataset. Repeating dataset and dropping remainder to achieve requested batch size.
123
+ [2024-07-23 16:08:56,169)](INFO)CIDSModelTF: Preprocessing...
124
+ [2024-07-23 16:08:56,453)](INFO)CIDSModelTF: Inferring...
125
+ [2024-07-23 16:09:00,119)](INFO)CIDSModelTF: Postprocessing...
126
+ [2024-07-23 16:09:00,384)](INFO)CIDSModelTF: Inference completed.
127
+ [2024-07-23 16:09:00,592)](INFO)httpx: HTTP Request: GET https://checkip.amazonaws.com/ "HTTP/1.1 200 "
128
+ [2024-07-23 16:09:00,821)](INFO)httpx: HTTP Request: GET http://127.0.0.1:7861/startup-events "HTTP/1.1 200 OK"
129
+ [2024-07-23 16:09:00,859)](INFO)httpx: HTTP Request: HEAD http://127.0.0.1:7861/ "HTTP/1.1 200 OK"
130
+ [2024-07-23 16:09:01,260)](INFO)httpx: HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
131
+ [2024-07-23 16:09:01,636)](INFO)httpx: HTTP Request: GET https://api.gradio.app/v2/tunnel-request "HTTP/1.1 200 OK"
DATA/ex-mnist/LOGS/2024-07-23_16-11-14_app.log ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [2024-07-23 16:11:14,890)](INFO)KadiAIProject: Logging to /mnt/data2/yinghanz/codes/frameworks/test/cids_gr_example/DATA/ex-mnist/LOGS/2024-07-23_16-11-14_app.log
2
+ [2024-07-23 16:11:14,892)](INFO)KadiAIProject: Setting seeds to: ex-mnist
3
+ [2024-07-23 16:11:14,895)](INFO)KadiAIProject: Loading from /mnt/data2/yinghanz/codes/frameworks/test/cids_gr_example/DATA/ex-mnist/project_ex-mnist.json
4
+ [2024-07-23 16:11:16,958)](INFO)KadiAIProject: Git commit: 143d0296
5
+ [2024-07-23 16:11:17,213)](INFO)CIDSModelTF: Single CPU found. Using one device distribution.
6
+ [2024-07-23 16:11:17,218)](INFO)KadiAIProject: >> Evaluating...
7
+ [2024-07-23 16:11:17,219)](INFO)KadiAIProject: >>> Metrics...
8
+ [2024-07-23 16:11:17,404)](WARNING)CIDSModelTF: Attempting to load checkpoint='last' but model.save_best_only = True. This will not load the final model state at the end of training but the last checkpoint that improved the model.monitor = 'val_accuracy'. Use checkpoint='last_phase' to get final state.
9
+ [2024-07-23 16:11:17,407)](INFO)CIDSModelTF: Continuing from epoch 16 (checkpoint 0000016).
10
+ [2024-07-23 16:11:17,509)](INFO)CIDSModelTF: Model Summary: mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10
11
+ [2024-07-23 16:11:17,510)](INFO)CIDSModelTF: Model: "InputPreprocess"
12
+ [2024-07-23 16:11:17,510)](INFO)CIDSModelTF: _________________________________________________________________
13
+ [2024-07-23 16:11:17,511)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
14
+ [2024-07-23 16:11:17,512)](INFO)CIDSModelTF: =================================================================
15
+ [2024-07-23 16:11:17,512)](INFO)CIDSModelTF: input_1 (InputLayer) [(None, 28, 28, 1)] 0
16
+ [2024-07-23 16:11:17,513)](INFO)CIDSModelTF:
17
+ [2024-07-23 16:11:17,514)](INFO)CIDSModelTF: tf.identity (TFOpLambda) (None, 28, 28, 1) 0
18
+ [2024-07-23 16:11:17,514)](INFO)CIDSModelTF:
19
+ [2024-07-23 16:11:17,515)](INFO)CIDSModelTF: tf.cast (TFOpLambda) (None, 28, 28, 1) 0
20
+ [2024-07-23 16:11:17,515)](INFO)CIDSModelTF:
21
+ [2024-07-23 16:11:17,516)](INFO)CIDSModelTF: =================================================================
22
+ [2024-07-23 16:11:17,517)](INFO)CIDSModelTF: Total params: 0
23
+ [2024-07-23 16:11:17,517)](INFO)CIDSModelTF: Trainable params: 0
24
+ [2024-07-23 16:11:17,518)](INFO)CIDSModelTF: Non-trainable params: 0
25
+ [2024-07-23 16:11:17,518)](INFO)CIDSModelTF: _________________________________________________________________
26
+ [2024-07-23 16:11:17,519)](INFO)CIDSModelTF: Model: "OutputPreprocess"
27
+ [2024-07-23 16:11:17,519)](INFO)CIDSModelTF: _________________________________________________________________
28
+ [2024-07-23 16:11:17,520)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
29
+ [2024-07-23 16:11:17,521)](INFO)CIDSModelTF: =================================================================
30
+ [2024-07-23 16:11:17,521)](INFO)CIDSModelTF: input_2 (InputLayer) [(None, 1)] 0
31
+ [2024-07-23 16:11:17,522)](INFO)CIDSModelTF:
32
+ [2024-07-23 16:11:17,522)](INFO)CIDSModelTF: tf.identity_1 (TFOpLambda) (None, 1) 0
33
+ [2024-07-23 16:11:17,523)](INFO)CIDSModelTF:
34
+ [2024-07-23 16:11:17,523)](INFO)CIDSModelTF: tf.__operators__.getitem (S (None,) 0
35
+ [2024-07-23 16:11:17,524)](INFO)CIDSModelTF: licingOpLambda)
36
+ [2024-07-23 16:11:17,524)](INFO)CIDSModelTF:
37
+ [2024-07-23 16:11:17,525)](INFO)CIDSModelTF: tf.cast_1 (TFOpLambda) (None,) 0
38
+ [2024-07-23 16:11:17,526)](INFO)CIDSModelTF:
39
+ [2024-07-23 16:11:17,526)](INFO)CIDSModelTF: tf.one_hot (TFOpLambda) (None, 10) 0
40
+ [2024-07-23 16:11:17,527)](INFO)CIDSModelTF:
41
+ [2024-07-23 16:11:17,527)](INFO)CIDSModelTF: tf.cast_2 (TFOpLambda) (None, 10) 0
42
+ [2024-07-23 16:11:17,528)](INFO)CIDSModelTF:
43
+ [2024-07-23 16:11:17,528)](INFO)CIDSModelTF: =================================================================
44
+ [2024-07-23 16:11:17,529)](INFO)CIDSModelTF: Total params: 0
45
+ [2024-07-23 16:11:17,529)](INFO)CIDSModelTF: Trainable params: 0
46
+ [2024-07-23 16:11:17,530)](INFO)CIDSModelTF: Non-trainable params: 0
47
+ [2024-07-23 16:11:17,531)](INFO)CIDSModelTF: _________________________________________________________________
48
+ [2024-07-23 16:11:17,531)](INFO)CIDSModelTF: Model: "Core"
49
+ [2024-07-23 16:11:17,532)](INFO)CIDSModelTF: _________________________________________________________________
50
+ [2024-07-23 16:11:17,532)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
51
+ [2024-07-23 16:11:17,533)](INFO)CIDSModelTF: =================================================================
52
+ [2024-07-23 16:11:17,533)](INFO)CIDSModelTF: input_3 (InputLayer) [(None, 28, 28, 1)] 0
53
+ [2024-07-23 16:11:17,534)](INFO)CIDSModelTF:
54
+ [2024-07-23 16:11:17,534)](INFO)CIDSModelTF: conv2d (Conv2D) (None, 28, 28, 64) 640
55
+ [2024-07-23 16:11:17,535)](INFO)CIDSModelTF:
56
+ [2024-07-23 16:11:17,535)](INFO)CIDSModelTF: re_lu (ReLU) (None, 28, 28, 64) 0
57
+ [2024-07-23 16:11:17,536)](INFO)CIDSModelTF:
58
+ [2024-07-23 16:11:17,537)](INFO)CIDSModelTF: conv2d_1 (Conv2D) (None, 28, 28, 64) 36928
59
+ [2024-07-23 16:11:17,537)](INFO)CIDSModelTF:
60
+ [2024-07-23 16:11:17,538)](INFO)CIDSModelTF: re_lu_1 (ReLU) (None, 28, 28, 64) 0
61
+ [2024-07-23 16:11:17,538)](INFO)CIDSModelTF:
62
+ [2024-07-23 16:11:17,539)](INFO)CIDSModelTF: max_pooling2d (MaxPooling2D (None, 14, 14, 64) 0
63
+ [2024-07-23 16:11:17,539)](INFO)CIDSModelTF: )
64
+ [2024-07-23 16:11:17,539)](INFO)CIDSModelTF:
65
+ [2024-07-23 16:11:17,540)](INFO)CIDSModelTF: batch_normalization (BatchN (None, 14, 14, 64) 256
66
+ [2024-07-23 16:11:17,540)](INFO)CIDSModelTF: ormalization)
67
+ [2024-07-23 16:11:17,541)](INFO)CIDSModelTF:
68
+ [2024-07-23 16:11:17,541)](INFO)CIDSModelTF: conv2d_2 (Conv2D) (None, 14, 14, 128) 73856
69
+ [2024-07-23 16:11:17,542)](INFO)CIDSModelTF:
70
+ [2024-07-23 16:11:17,542)](INFO)CIDSModelTF: re_lu_2 (ReLU) (None, 14, 14, 128) 0
71
+ [2024-07-23 16:11:17,543)](INFO)CIDSModelTF:
72
+ [2024-07-23 16:11:17,544)](INFO)CIDSModelTF: conv2d_3 (Conv2D) (None, 14, 14, 128) 147584
73
+ [2024-07-23 16:11:17,544)](INFO)CIDSModelTF:
74
+ [2024-07-23 16:11:17,545)](INFO)CIDSModelTF: re_lu_3 (ReLU) (None, 14, 14, 128) 0
75
+ [2024-07-23 16:11:17,545)](INFO)CIDSModelTF:
76
+ [2024-07-23 16:11:17,546)](INFO)CIDSModelTF: max_pooling2d_1 (MaxPooling (None, 7, 7, 128) 0
77
+ [2024-07-23 16:11:17,546)](INFO)CIDSModelTF: 2D)
78
+ [2024-07-23 16:11:17,547)](INFO)CIDSModelTF:
79
+ [2024-07-23 16:11:17,547)](INFO)CIDSModelTF: batch_normalization_1 (Batc (None, 7, 7, 128) 512
80
+ [2024-07-23 16:11:17,547)](INFO)CIDSModelTF: hNormalization)
81
+ [2024-07-23 16:11:17,548)](INFO)CIDSModelTF:
82
+ [2024-07-23 16:11:17,548)](INFO)CIDSModelTF: conv2d_4 (Conv2D) (None, 7, 7, 256) 295168
83
+ [2024-07-23 16:11:17,549)](INFO)CIDSModelTF:
84
+ [2024-07-23 16:11:17,550)](INFO)CIDSModelTF: max_pooling2d_2 (MaxPooling (None, 3, 3, 256) 0
85
+ [2024-07-23 16:11:17,550)](INFO)CIDSModelTF: 2D)
86
+ [2024-07-23 16:11:17,550)](INFO)CIDSModelTF:
87
+ [2024-07-23 16:11:17,551)](INFO)CIDSModelTF: flatten (Flatten) (None, 2304) 0
88
+ [2024-07-23 16:11:17,551)](INFO)CIDSModelTF:
89
+ [2024-07-23 16:11:17,552)](INFO)CIDSModelTF: dropout (Dropout) (None, 2304) 0
90
+ [2024-07-23 16:11:17,552)](INFO)CIDSModelTF:
91
+ [2024-07-23 16:11:17,553)](INFO)CIDSModelTF: dense (Dense) (None, 512) 1180160
92
+ [2024-07-23 16:11:17,553)](INFO)CIDSModelTF:
93
+ [2024-07-23 16:11:17,554)](INFO)CIDSModelTF: dense_1 (Dense) (None, 10) 5130
94
+ [2024-07-23 16:11:17,554)](INFO)CIDSModelTF:
95
+ [2024-07-23 16:11:17,555)](INFO)CIDSModelTF: =================================================================
96
+ [2024-07-23 16:11:17,555)](INFO)CIDSModelTF: Total params: 1,740,234
97
+ [2024-07-23 16:11:17,556)](INFO)CIDSModelTF: Trainable params: 1,739,850
98
+ [2024-07-23 16:11:17,556)](INFO)CIDSModelTF: Non-trainable params: 384
99
+ [2024-07-23 16:11:17,557)](INFO)CIDSModelTF: _________________________________________________________________
100
+ [2024-07-23 16:11:17,557)](INFO)CIDSModelTF: Model: "Postprocess"
101
+ [2024-07-23 16:11:17,557)](INFO)CIDSModelTF: _________________________________________________________________
102
+ [2024-07-23 16:11:17,558)](INFO)CIDSModelTF: Layer (type) Output Shape Param #
103
+ [2024-07-23 16:11:17,558)](INFO)CIDSModelTF: =================================================================
104
+ [2024-07-23 16:11:17,559)](INFO)CIDSModelTF: input_5 (InputLayer) [(None, 10)] 0
105
+ [2024-07-23 16:11:17,559)](INFO)CIDSModelTF:
106
+ [2024-07-23 16:11:17,560)](INFO)CIDSModelTF: tf.math.argmax (TFOpLambda) (None,) 0
107
+ [2024-07-23 16:11:17,560)](INFO)CIDSModelTF:
108
+ [2024-07-23 16:11:17,561)](INFO)CIDSModelTF: tf.expand_dims (TFOpLambda) (None, 1) 0
109
+ [2024-07-23 16:11:17,561)](INFO)CIDSModelTF:
110
+ [2024-07-23 16:11:17,562)](INFO)CIDSModelTF: =================================================================
111
+ [2024-07-23 16:11:17,562)](INFO)CIDSModelTF: Total params: 0
112
+ [2024-07-23 16:11:17,562)](INFO)CIDSModelTF: Trainable params: 0
113
+ [2024-07-23 16:11:17,563)](INFO)CIDSModelTF: Non-trainable params: 0
114
+ [2024-07-23 16:11:17,563)](INFO)CIDSModelTF: _________________________________________________________________
115
+ [2024-07-23 16:11:17,565)](INFO)CIDSModelTF: Estimated memory (Core model): 0.012000 GBytes
116
+ [2024-07-23 16:11:17,566)](INFO)CIDSModelTF: Estimated memory (Input preprocess model): 0.000000 GBytes
117
+ [2024-07-23 16:11:17,566)](INFO)CIDSModelTF: Estimated memory (Output preprocess model): 0.000000 GBytes
118
+ [2024-07-23 16:11:17,567)](INFO)CIDSModelTF: Estimated memory (Postprocess model): 0.000000 GBytes
119
+ [2024-07-23 16:11:17,568)](INFO)DataReader: (test) Estimated sample size: 0.00309086 MB.
120
+ [2024-07-23 16:11:17,568)](INFO)DataReader: (test) buffer_size set to maximum number of samples (1).
121
+ [2024-07-23 16:11:17,954)](INFO)DataReader: (test) Caching dataset. Disable by setting model.data_reader.prefetch = True. Currently set to: "cache".
122
+ [2024-07-23 16:11:17,960)](WARNING)DataReader: Batch size is larger than dataset. Repeating dataset and dropping remainder to achieve requested batch size.
123
+ [2024-07-23 16:11:18,478)](INFO)CIDSModelTF: Preprocessing...
124
+ [2024-07-23 16:11:18,774)](INFO)CIDSModelTF: Inferring...
125
+ [2024-07-23 16:11:22,431)](INFO)CIDSModelTF: Postprocessing...
126
+ [2024-07-23 16:11:22,695)](INFO)CIDSModelTF: Inference completed.
127
+ [2024-07-23 16:11:22,887)](INFO)httpx: HTTP Request: GET https://checkip.amazonaws.com/ "HTTP/1.1 200 "
128
+ [2024-07-23 16:11:23,163)](INFO)httpx: HTTP Request: GET http://127.0.0.1:7861/startup-events "HTTP/1.1 200 OK"
129
+ [2024-07-23 16:11:23,193)](INFO)httpx: HTTP Request: HEAD http://127.0.0.1:7861/ "HTTP/1.1 200 OK"
130
+ [2024-07-23 16:11:23,490)](INFO)httpx: HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
131
+ [2024-07-23 16:11:23,954)](INFO)httpx: HTTP Request: GET https://api.gradio.app/v2/tunnel-request "HTTP/1.1 200 OK"
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/cidsmodel.json ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "key": "CIDS:Model",
3
+ "type": "dict",
4
+ "value": [
5
+ {
6
+ "key": "Name",
7
+ "type": "str",
8
+ "value": "mnist--image--label--onehot"
9
+ },
10
+ {
11
+ "key": "Hyperparameters",
12
+ "type": "dict",
13
+ "value": [
14
+ {
15
+ "key": "Model",
16
+ "type": "dict",
17
+ "value": []
18
+ },
19
+ {
20
+ "key": "Training",
21
+ "type": "dict",
22
+ "value": [
23
+ {
24
+ "key": "learning_rate",
25
+ "type": "float",
26
+ "validation": {
27
+ "options": [
28
+ 0.003,
29
+ 0.001,
30
+ 0.0003,
31
+ 0.0001,
32
+ 3e-05,
33
+ 1e-05
34
+ ],
35
+ "required": true
36
+ },
37
+ "value": 0.0001
38
+ },
39
+ {
40
+ "key": "num_kernels",
41
+ "type": "int",
42
+ "validation": {
43
+ "options": [
44
+ 32,
45
+ 64,
46
+ 128,
47
+ 256,
48
+ 512
49
+ ],
50
+ "required": true
51
+ },
52
+ "value": 64
53
+ },
54
+ {
55
+ "key": "dropout",
56
+ "type": "float",
57
+ "validation": {
58
+ "options": [
59
+ 0.0,
60
+ 0.07,
61
+ 0.14,
62
+ 0.21,
63
+ 0.28,
64
+ 0.3,
65
+ 0.35,
66
+ 0.42,
67
+ 0.49,
68
+ 0.56,
69
+ 0.63
70
+ ],
71
+ "required": true
72
+ },
73
+ "value": 0.3
74
+ }
75
+ ]
76
+ }
77
+ ]
78
+ }
79
+ ]
80
+ }
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/0000016/input_preprocess_weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:353a95b9c5c02a59fc51ce2e3b99d1bf28d0a24389a391c6cd869b8e452bf8e3
3
+ size 8752
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/0000016/model_weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5a979b2e91d953d3d7d15a028b9b9edcc1a8aab3cbeadce74d5322c7baa2c7a7
3
+ size 7003288
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/0000016/output_preprocess_weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:715402a4e30c5a8aa6da24d69934982057a5528e69f16e1b1c6a971c72675f35
3
+ size 11336
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase00/input_preprocess_weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:353a95b9c5c02a59fc51ce2e3b99d1bf28d0a24389a391c6cd869b8e452bf8e3
3
+ size 8752
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase00/model_weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b12b887f02321603369822e5bbb7aac13de5fbc3df0157a1304e1dc897cf94e
3
+ size 7003288
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase00/output_preprocess_weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:715402a4e30c5a8aa6da24d69934982057a5528e69f16e1b1c6a971c72675f35
3
+ size 11336
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase01/input_preprocess_weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:353a95b9c5c02a59fc51ce2e3b99d1bf28d0a24389a391c6cd869b8e452bf8e3
3
+ size 8752
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase01/model_weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6de4f94c7960e1bcb5ea008d3e773e324adf011e689775fde5e07aa97b7c70e5
3
+ size 7003288
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/checkpoint/phase01/output_preprocess_weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:715402a4e30c5a8aa6da24d69934982057a5528e69f16e1b1c6a971c72675f35
3
+ size 11336
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/hp.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"space": [{"class_name": "Choice", "config": {"name": "learning_rate", "default": 0.0001, "conditions": [], "values": [0.003, 0.001, 0.0003, 0.0001, 3e-05, 1e-05], "ordered": true}}, {"class_name": "Choice", "config": {"name": "num_kernels", "default": 64, "conditions": [], "values": [32, 64, 128, 256, 512], "ordered": true}}, {"class_name": "Float", "config": {"name": "dropout", "default": 0.3, "conditions": [], "min_value": 0.0, "max_value": 0.7, "step": null, "sampling": "linear"}}], "values": {"learning_rate": 0.0001, "num_kernels": 64, "dropout": 0.3}}
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/model.json ADDED
@@ -0,0 +1,1030 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": {
3
+ "core_model": {
4
+ "input_layers": [
5
+ [
6
+ [
7
+ "input_3",
8
+ 0,
9
+ 0
10
+ ]
11
+ ]
12
+ ],
13
+ "layers": [
14
+ {
15
+ "class_name": "InputLayer",
16
+ "config": {
17
+ "batch_input_shape": [
18
+ null,
19
+ 28,
20
+ 28,
21
+ 1
22
+ ],
23
+ "dtype": "float32",
24
+ "name": "input_3",
25
+ "ragged": false,
26
+ "sparse": false
27
+ },
28
+ "inbound_nodes": [],
29
+ "name": "input_3"
30
+ },
31
+ {
32
+ "class_name": "Conv2D",
33
+ "config": {
34
+ "activation": "linear",
35
+ "activity_regularizer": null,
36
+ "bias_constraint": null,
37
+ "bias_initializer": {
38
+ "class_name": "Zeros",
39
+ "config": {}
40
+ },
41
+ "bias_regularizer": null,
42
+ "data_format": "channels_last",
43
+ "dilation_rate": [
44
+ 1,
45
+ 1
46
+ ],
47
+ "dtype": "float32",
48
+ "filters": 64,
49
+ "groups": 1,
50
+ "kernel_constraint": null,
51
+ "kernel_initializer": {
52
+ "class_name": "GlorotUniform",
53
+ "config": {
54
+ "seed": null
55
+ }
56
+ },
57
+ "kernel_regularizer": null,
58
+ "kernel_size": [
59
+ 3,
60
+ 3
61
+ ],
62
+ "name": "conv2d",
63
+ "padding": "same",
64
+ "strides": [
65
+ 1,
66
+ 1
67
+ ],
68
+ "trainable": true,
69
+ "use_bias": true
70
+ },
71
+ "inbound_nodes": [
72
+ [
73
+ [
74
+ "input_3",
75
+ 0,
76
+ 0,
77
+ {}
78
+ ]
79
+ ]
80
+ ],
81
+ "name": "conv2d"
82
+ },
83
+ {
84
+ "class_name": "ReLU",
85
+ "config": {
86
+ "dtype": "float32",
87
+ "max_value": null,
88
+ "name": "re_lu",
89
+ "negative_slope": 0.0,
90
+ "threshold": 0.0,
91
+ "trainable": true
92
+ },
93
+ "inbound_nodes": [
94
+ [
95
+ [
96
+ "conv2d",
97
+ 0,
98
+ 0,
99
+ {}
100
+ ]
101
+ ]
102
+ ],
103
+ "name": "re_lu"
104
+ },
105
+ {
106
+ "class_name": "Conv2D",
107
+ "config": {
108
+ "activation": "linear",
109
+ "activity_regularizer": null,
110
+ "bias_constraint": null,
111
+ "bias_initializer": {
112
+ "class_name": "Zeros",
113
+ "config": {}
114
+ },
115
+ "bias_regularizer": null,
116
+ "data_format": "channels_last",
117
+ "dilation_rate": [
118
+ 1,
119
+ 1
120
+ ],
121
+ "dtype": "float32",
122
+ "filters": 64,
123
+ "groups": 1,
124
+ "kernel_constraint": null,
125
+ "kernel_initializer": {
126
+ "class_name": "GlorotUniform",
127
+ "config": {
128
+ "seed": null
129
+ }
130
+ },
131
+ "kernel_regularizer": null,
132
+ "kernel_size": [
133
+ 3,
134
+ 3
135
+ ],
136
+ "name": "conv2d_1",
137
+ "padding": "same",
138
+ "strides": [
139
+ 1,
140
+ 1
141
+ ],
142
+ "trainable": true,
143
+ "use_bias": true
144
+ },
145
+ "inbound_nodes": [
146
+ [
147
+ [
148
+ "re_lu",
149
+ 0,
150
+ 0,
151
+ {}
152
+ ]
153
+ ]
154
+ ],
155
+ "name": "conv2d_1"
156
+ },
157
+ {
158
+ "class_name": "ReLU",
159
+ "config": {
160
+ "dtype": "float32",
161
+ "max_value": null,
162
+ "name": "re_lu_1",
163
+ "negative_slope": 0.0,
164
+ "threshold": 0.0,
165
+ "trainable": true
166
+ },
167
+ "inbound_nodes": [
168
+ [
169
+ [
170
+ "conv2d_1",
171
+ 0,
172
+ 0,
173
+ {}
174
+ ]
175
+ ]
176
+ ],
177
+ "name": "re_lu_1"
178
+ },
179
+ {
180
+ "class_name": "MaxPooling2D",
181
+ "config": {
182
+ "data_format": "channels_last",
183
+ "dtype": "float32",
184
+ "name": "max_pooling2d",
185
+ "padding": "valid",
186
+ "pool_size": [
187
+ 2,
188
+ 2
189
+ ],
190
+ "strides": [
191
+ 2,
192
+ 2
193
+ ],
194
+ "trainable": true
195
+ },
196
+ "inbound_nodes": [
197
+ [
198
+ [
199
+ "re_lu_1",
200
+ 0,
201
+ 0,
202
+ {}
203
+ ]
204
+ ]
205
+ ],
206
+ "name": "max_pooling2d"
207
+ },
208
+ {
209
+ "class_name": "BatchNormalization",
210
+ "config": {
211
+ "axis": [
212
+ 3
213
+ ],
214
+ "beta_constraint": null,
215
+ "beta_initializer": {
216
+ "class_name": "Zeros",
217
+ "config": {}
218
+ },
219
+ "beta_regularizer": null,
220
+ "center": true,
221
+ "dtype": "float32",
222
+ "epsilon": 0.001,
223
+ "gamma_constraint": null,
224
+ "gamma_initializer": {
225
+ "class_name": "Ones",
226
+ "config": {}
227
+ },
228
+ "gamma_regularizer": null,
229
+ "momentum": 0.99,
230
+ "moving_mean_initializer": {
231
+ "class_name": "Zeros",
232
+ "config": {}
233
+ },
234
+ "moving_variance_initializer": {
235
+ "class_name": "Ones",
236
+ "config": {}
237
+ },
238
+ "name": "batch_normalization",
239
+ "scale": true,
240
+ "trainable": true
241
+ },
242
+ "inbound_nodes": [
243
+ [
244
+ [
245
+ "max_pooling2d",
246
+ 0,
247
+ 0,
248
+ {}
249
+ ]
250
+ ]
251
+ ],
252
+ "name": "batch_normalization"
253
+ },
254
+ {
255
+ "class_name": "Conv2D",
256
+ "config": {
257
+ "activation": "linear",
258
+ "activity_regularizer": null,
259
+ "bias_constraint": null,
260
+ "bias_initializer": {
261
+ "class_name": "Zeros",
262
+ "config": {}
263
+ },
264
+ "bias_regularizer": null,
265
+ "data_format": "channels_last",
266
+ "dilation_rate": [
267
+ 1,
268
+ 1
269
+ ],
270
+ "dtype": "float32",
271
+ "filters": 128,
272
+ "groups": 1,
273
+ "kernel_constraint": null,
274
+ "kernel_initializer": {
275
+ "class_name": "GlorotUniform",
276
+ "config": {
277
+ "seed": null
278
+ }
279
+ },
280
+ "kernel_regularizer": null,
281
+ "kernel_size": [
282
+ 3,
283
+ 3
284
+ ],
285
+ "name": "conv2d_2",
286
+ "padding": "same",
287
+ "strides": [
288
+ 1,
289
+ 1
290
+ ],
291
+ "trainable": true,
292
+ "use_bias": true
293
+ },
294
+ "inbound_nodes": [
295
+ [
296
+ [
297
+ "batch_normalization",
298
+ 0,
299
+ 0,
300
+ {}
301
+ ]
302
+ ]
303
+ ],
304
+ "name": "conv2d_2"
305
+ },
306
+ {
307
+ "class_name": "ReLU",
308
+ "config": {
309
+ "dtype": "float32",
310
+ "max_value": null,
311
+ "name": "re_lu_2",
312
+ "negative_slope": 0.0,
313
+ "threshold": 0.0,
314
+ "trainable": true
315
+ },
316
+ "inbound_nodes": [
317
+ [
318
+ [
319
+ "conv2d_2",
320
+ 0,
321
+ 0,
322
+ {}
323
+ ]
324
+ ]
325
+ ],
326
+ "name": "re_lu_2"
327
+ },
328
+ {
329
+ "class_name": "Conv2D",
330
+ "config": {
331
+ "activation": "linear",
332
+ "activity_regularizer": null,
333
+ "bias_constraint": null,
334
+ "bias_initializer": {
335
+ "class_name": "Zeros",
336
+ "config": {}
337
+ },
338
+ "bias_regularizer": null,
339
+ "data_format": "channels_last",
340
+ "dilation_rate": [
341
+ 1,
342
+ 1
343
+ ],
344
+ "dtype": "float32",
345
+ "filters": 128,
346
+ "groups": 1,
347
+ "kernel_constraint": null,
348
+ "kernel_initializer": {
349
+ "class_name": "GlorotUniform",
350
+ "config": {
351
+ "seed": null
352
+ }
353
+ },
354
+ "kernel_regularizer": null,
355
+ "kernel_size": [
356
+ 3,
357
+ 3
358
+ ],
359
+ "name": "conv2d_3",
360
+ "padding": "same",
361
+ "strides": [
362
+ 1,
363
+ 1
364
+ ],
365
+ "trainable": true,
366
+ "use_bias": true
367
+ },
368
+ "inbound_nodes": [
369
+ [
370
+ [
371
+ "re_lu_2",
372
+ 0,
373
+ 0,
374
+ {}
375
+ ]
376
+ ]
377
+ ],
378
+ "name": "conv2d_3"
379
+ },
380
+ {
381
+ "class_name": "ReLU",
382
+ "config": {
383
+ "dtype": "float32",
384
+ "max_value": null,
385
+ "name": "re_lu_3",
386
+ "negative_slope": 0.0,
387
+ "threshold": 0.0,
388
+ "trainable": true
389
+ },
390
+ "inbound_nodes": [
391
+ [
392
+ [
393
+ "conv2d_3",
394
+ 0,
395
+ 0,
396
+ {}
397
+ ]
398
+ ]
399
+ ],
400
+ "name": "re_lu_3"
401
+ },
402
+ {
403
+ "class_name": "MaxPooling2D",
404
+ "config": {
405
+ "data_format": "channels_last",
406
+ "dtype": "float32",
407
+ "name": "max_pooling2d_1",
408
+ "padding": "valid",
409
+ "pool_size": [
410
+ 2,
411
+ 2
412
+ ],
413
+ "strides": [
414
+ 2,
415
+ 2
416
+ ],
417
+ "trainable": true
418
+ },
419
+ "inbound_nodes": [
420
+ [
421
+ [
422
+ "re_lu_3",
423
+ 0,
424
+ 0,
425
+ {}
426
+ ]
427
+ ]
428
+ ],
429
+ "name": "max_pooling2d_1"
430
+ },
431
+ {
432
+ "class_name": "BatchNormalization",
433
+ "config": {
434
+ "axis": [
435
+ 3
436
+ ],
437
+ "beta_constraint": null,
438
+ "beta_initializer": {
439
+ "class_name": "Zeros",
440
+ "config": {}
441
+ },
442
+ "beta_regularizer": null,
443
+ "center": true,
444
+ "dtype": "float32",
445
+ "epsilon": 0.001,
446
+ "gamma_constraint": null,
447
+ "gamma_initializer": {
448
+ "class_name": "Ones",
449
+ "config": {}
450
+ },
451
+ "gamma_regularizer": null,
452
+ "momentum": 0.99,
453
+ "moving_mean_initializer": {
454
+ "class_name": "Zeros",
455
+ "config": {}
456
+ },
457
+ "moving_variance_initializer": {
458
+ "class_name": "Ones",
459
+ "config": {}
460
+ },
461
+ "name": "batch_normalization_1",
462
+ "scale": true,
463
+ "trainable": true
464
+ },
465
+ "inbound_nodes": [
466
+ [
467
+ [
468
+ "max_pooling2d_1",
469
+ 0,
470
+ 0,
471
+ {}
472
+ ]
473
+ ]
474
+ ],
475
+ "name": "batch_normalization_1"
476
+ },
477
+ {
478
+ "class_name": "Conv2D",
479
+ "config": {
480
+ "activation": "linear",
481
+ "activity_regularizer": null,
482
+ "bias_constraint": null,
483
+ "bias_initializer": {
484
+ "class_name": "Zeros",
485
+ "config": {}
486
+ },
487
+ "bias_regularizer": null,
488
+ "data_format": "channels_last",
489
+ "dilation_rate": [
490
+ 1,
491
+ 1
492
+ ],
493
+ "dtype": "float32",
494
+ "filters": 256,
495
+ "groups": 1,
496
+ "kernel_constraint": null,
497
+ "kernel_initializer": {
498
+ "class_name": "GlorotUniform",
499
+ "config": {
500
+ "seed": null
501
+ }
502
+ },
503
+ "kernel_regularizer": null,
504
+ "kernel_size": [
505
+ 3,
506
+ 3
507
+ ],
508
+ "name": "conv2d_4",
509
+ "padding": "same",
510
+ "strides": [
511
+ 1,
512
+ 1
513
+ ],
514
+ "trainable": true,
515
+ "use_bias": true
516
+ },
517
+ "inbound_nodes": [
518
+ [
519
+ [
520
+ "batch_normalization_1",
521
+ 0,
522
+ 0,
523
+ {}
524
+ ]
525
+ ]
526
+ ],
527
+ "name": "conv2d_4"
528
+ },
529
+ {
530
+ "class_name": "MaxPooling2D",
531
+ "config": {
532
+ "data_format": "channels_last",
533
+ "dtype": "float32",
534
+ "name": "max_pooling2d_2",
535
+ "padding": "valid",
536
+ "pool_size": [
537
+ 2,
538
+ 2
539
+ ],
540
+ "strides": [
541
+ 2,
542
+ 2
543
+ ],
544
+ "trainable": true
545
+ },
546
+ "inbound_nodes": [
547
+ [
548
+ [
549
+ "conv2d_4",
550
+ 0,
551
+ 0,
552
+ {}
553
+ ]
554
+ ]
555
+ ],
556
+ "name": "max_pooling2d_2"
557
+ },
558
+ {
559
+ "class_name": "Flatten",
560
+ "config": {
561
+ "data_format": "channels_last",
562
+ "dtype": "float32",
563
+ "name": "flatten",
564
+ "trainable": true
565
+ },
566
+ "inbound_nodes": [
567
+ [
568
+ [
569
+ "max_pooling2d_2",
570
+ 0,
571
+ 0,
572
+ {}
573
+ ]
574
+ ]
575
+ ],
576
+ "name": "flatten"
577
+ },
578
+ {
579
+ "class_name": "Dropout",
580
+ "config": {
581
+ "dtype": "float32",
582
+ "name": "dropout",
583
+ "noise_shape": null,
584
+ "rate": 0.3,
585
+ "seed": null,
586
+ "trainable": true
587
+ },
588
+ "inbound_nodes": [
589
+ [
590
+ [
591
+ "flatten",
592
+ 0,
593
+ 0,
594
+ {}
595
+ ]
596
+ ]
597
+ ],
598
+ "name": "dropout"
599
+ },
600
+ {
601
+ "class_name": "Dense",
602
+ "config": {
603
+ "activation": "linear",
604
+ "activity_regularizer": null,
605
+ "bias_constraint": null,
606
+ "bias_initializer": {
607
+ "class_name": "Zeros",
608
+ "config": {}
609
+ },
610
+ "bias_regularizer": null,
611
+ "dtype": "float32",
612
+ "kernel_constraint": null,
613
+ "kernel_initializer": {
614
+ "class_name": "GlorotUniform",
615
+ "config": {
616
+ "seed": null
617
+ }
618
+ },
619
+ "kernel_regularizer": null,
620
+ "name": "dense",
621
+ "trainable": true,
622
+ "units": 512,
623
+ "use_bias": true
624
+ },
625
+ "inbound_nodes": [
626
+ [
627
+ [
628
+ "dropout",
629
+ 0,
630
+ 0,
631
+ {}
632
+ ]
633
+ ]
634
+ ],
635
+ "name": "dense"
636
+ },
637
+ {
638
+ "class_name": "Dense",
639
+ "config": {
640
+ "activation": "softmax",
641
+ "activity_regularizer": null,
642
+ "bias_constraint": null,
643
+ "bias_initializer": {
644
+ "class_name": "Zeros",
645
+ "config": {}
646
+ },
647
+ "bias_regularizer": null,
648
+ "dtype": "float32",
649
+ "kernel_constraint": null,
650
+ "kernel_initializer": {
651
+ "class_name": "GlorotUniform",
652
+ "config": {
653
+ "seed": null
654
+ }
655
+ },
656
+ "kernel_regularizer": null,
657
+ "name": "dense_1",
658
+ "trainable": true,
659
+ "units": 10,
660
+ "use_bias": true
661
+ },
662
+ "inbound_nodes": [
663
+ [
664
+ [
665
+ "dense",
666
+ 0,
667
+ 0,
668
+ {}
669
+ ]
670
+ ]
671
+ ],
672
+ "name": "dense_1"
673
+ }
674
+ ],
675
+ "name": "Core",
676
+ "output_layers": [
677
+ [
678
+ "dense_1",
679
+ 0,
680
+ 0
681
+ ]
682
+ ]
683
+ },
684
+ "input_preprocess_model": {
685
+ "input_layers": [
686
+ [
687
+ "input_1",
688
+ 0,
689
+ 0
690
+ ]
691
+ ],
692
+ "layers": [
693
+ {
694
+ "class_name": "InputLayer",
695
+ "config": {
696
+ "batch_input_shape": [
697
+ null,
698
+ 28,
699
+ 28,
700
+ 1
701
+ ],
702
+ "dtype": "float32",
703
+ "name": "input_1",
704
+ "ragged": false,
705
+ "sparse": false
706
+ },
707
+ "inbound_nodes": [],
708
+ "name": "input_1"
709
+ },
710
+ {
711
+ "class_name": "TFOpLambda",
712
+ "config": {
713
+ "dtype": "float32",
714
+ "function": "identity",
715
+ "name": "tf.identity",
716
+ "trainable": true
717
+ },
718
+ "inbound_nodes": [
719
+ [
720
+ "input_1",
721
+ 0,
722
+ 0,
723
+ {}
724
+ ]
725
+ ],
726
+ "name": "tf.identity"
727
+ },
728
+ {
729
+ "class_name": "TFOpLambda",
730
+ "config": {
731
+ "dtype": "float32",
732
+ "function": "cast",
733
+ "name": "tf.cast",
734
+ "trainable": true
735
+ },
736
+ "inbound_nodes": [
737
+ [
738
+ "tf.identity",
739
+ 0,
740
+ 0,
741
+ {
742
+ "dtype": "tf.float32"
743
+ }
744
+ ]
745
+ ],
746
+ "name": "tf.cast"
747
+ }
748
+ ],
749
+ "name": "InputPreprocess",
750
+ "output_layers": [
751
+ [
752
+ "tf.cast",
753
+ 0,
754
+ 0
755
+ ]
756
+ ]
757
+ },
758
+ "output_preprocess_model": {
759
+ "input_layers": [
760
+ [
761
+ "input_2",
762
+ 0,
763
+ 0
764
+ ]
765
+ ],
766
+ "layers": [
767
+ {
768
+ "class_name": "InputLayer",
769
+ "config": {
770
+ "batch_input_shape": [
771
+ null,
772
+ 1
773
+ ],
774
+ "dtype": "float32",
775
+ "name": "input_2",
776
+ "ragged": false,
777
+ "sparse": false
778
+ },
779
+ "inbound_nodes": [],
780
+ "name": "input_2"
781
+ },
782
+ {
783
+ "class_name": "TFOpLambda",
784
+ "config": {
785
+ "dtype": "float32",
786
+ "function": "identity",
787
+ "name": "tf.identity_1",
788
+ "trainable": true
789
+ },
790
+ "inbound_nodes": [
791
+ [
792
+ "input_2",
793
+ 0,
794
+ 0,
795
+ {}
796
+ ]
797
+ ],
798
+ "name": "tf.identity_1"
799
+ },
800
+ {
801
+ "class_name": "SlicingOpLambda",
802
+ "config": {
803
+ "dtype": "float32",
804
+ "function": "__operators__.getitem",
805
+ "name": "tf.__operators__.getitem",
806
+ "trainable": true
807
+ },
808
+ "inbound_nodes": [
809
+ [
810
+ "tf.identity_1",
811
+ 0,
812
+ 0,
813
+ {
814
+ "slice_spec": [
815
+ "Ellipsis",
816
+ 0
817
+ ]
818
+ }
819
+ ]
820
+ ],
821
+ "name": "tf.__operators__.getitem"
822
+ },
823
+ {
824
+ "class_name": "TFOpLambda",
825
+ "config": {
826
+ "dtype": "float32",
827
+ "function": "cast",
828
+ "name": "tf.cast_1",
829
+ "trainable": true
830
+ },
831
+ "inbound_nodes": [
832
+ [
833
+ "tf.__operators__.getitem",
834
+ 0,
835
+ 0,
836
+ {
837
+ "dtype": "tf.int32"
838
+ }
839
+ ]
840
+ ],
841
+ "name": "tf.cast_1"
842
+ },
843
+ {
844
+ "class_name": "TFOpLambda",
845
+ "config": {
846
+ "dtype": "float32",
847
+ "function": "one_hot",
848
+ "name": "tf.one_hot",
849
+ "trainable": true
850
+ },
851
+ "inbound_nodes": [
852
+ [
853
+ "tf.cast_1",
854
+ 0,
855
+ 0,
856
+ {
857
+ "depth": 10
858
+ }
859
+ ]
860
+ ],
861
+ "name": "tf.one_hot"
862
+ },
863
+ {
864
+ "class_name": "TFOpLambda",
865
+ "config": {
866
+ "dtype": "float32",
867
+ "function": "cast",
868
+ "name": "tf.cast_2",
869
+ "trainable": true
870
+ },
871
+ "inbound_nodes": [
872
+ [
873
+ "tf.one_hot",
874
+ 0,
875
+ 0,
876
+ {
877
+ "dtype": "tf.float32"
878
+ }
879
+ ]
880
+ ],
881
+ "name": "tf.cast_2"
882
+ }
883
+ ],
884
+ "name": "OutputPreprocess",
885
+ "output_layers": [
886
+ [
887
+ "tf.cast_2",
888
+ 0,
889
+ 0
890
+ ]
891
+ ]
892
+ },
893
+ "postprocess_model": {
894
+ "input_layers": [
895
+ [
896
+ "input_5",
897
+ 0,
898
+ 0
899
+ ]
900
+ ],
901
+ "layers": [
902
+ {
903
+ "class_name": "InputLayer",
904
+ "config": {
905
+ "batch_input_shape": [
906
+ null,
907
+ 10
908
+ ],
909
+ "dtype": "float32",
910
+ "name": "input_5",
911
+ "ragged": false,
912
+ "sparse": false
913
+ },
914
+ "inbound_nodes": [],
915
+ "name": "input_5"
916
+ },
917
+ {
918
+ "class_name": "TFOpLambda",
919
+ "config": {
920
+ "dtype": "float32",
921
+ "function": "math.argmax",
922
+ "name": "tf.math.argmax",
923
+ "trainable": true
924
+ },
925
+ "inbound_nodes": [
926
+ [
927
+ "input_5",
928
+ 0,
929
+ 0,
930
+ {
931
+ "axis": -1
932
+ }
933
+ ]
934
+ ],
935
+ "name": "tf.math.argmax"
936
+ },
937
+ {
938
+ "class_name": "TFOpLambda",
939
+ "config": {
940
+ "dtype": "float32",
941
+ "function": "expand_dims",
942
+ "name": "tf.expand_dims",
943
+ "trainable": true
944
+ },
945
+ "inbound_nodes": [
946
+ [
947
+ "tf.math.argmax",
948
+ 0,
949
+ 0,
950
+ {
951
+ "axis": -1
952
+ }
953
+ ]
954
+ ],
955
+ "name": "tf.expand_dims"
956
+ }
957
+ ],
958
+ "name": "Postprocess",
959
+ "output_layers": [
960
+ [
961
+ "tf.expand_dims",
962
+ 0,
963
+ 0
964
+ ]
965
+ ]
966
+ },
967
+ "settings": {
968
+ "VERBOSITY": 2,
969
+ "_best_monitor": 0.9915555715560913,
970
+ "_callbacks": [
971
+ "<cids.tensorflow.callbacks.FreezeControl object at 0x7f61cc666230>"
972
+ ],
973
+ "_checkpoint_format_str": "{epoch:07d}",
974
+ "_collapse_repeated_features": false,
975
+ "_encode_categorical": "outputs",
976
+ "_hp": "<keras_tuner.src.engine.hyperparameters.hyperparameters.HyperParameters object at 0x7f6274542fe0>",
977
+ "_logger": "<Logger CIDSModelTF (INFO)>",
978
+ "_online_normalize": false,
979
+ "base_name": "mnist--image--label--onehot",
980
+ "built": true,
981
+ "built_input_shape": [
982
+ null,
983
+ 28,
984
+ 28,
985
+ 1
986
+ ],
987
+ "built_output_shape": [
988
+ null,
989
+ 1
990
+ ],
991
+ "built_submodels": null,
992
+ "conditional_inp": [],
993
+ "count": 21,
994
+ "count_mode": "epochs",
995
+ "data_definition": "<cids.data.definition.DataDefinition object at 0x7f62e05514b0>",
996
+ "data_reader": "<cids.data.reader.DataReader object at 0x7f61cc6661d0>",
997
+ "dtype": "tf.float32",
998
+ "identifier": "default",
999
+ "initial_count": 21,
1000
+ "input_online_normalizer": null,
1001
+ "loss_weights": [],
1002
+ "meta_architecture": "serial",
1003
+ "meta_folder": "",
1004
+ "metrics": [
1005
+ "accuracy"
1006
+ ],
1007
+ "monitor": "val_accuracy",
1008
+ "num_classes": 10,
1009
+ "num_gpus": 0,
1010
+ "optimizer": null,
1011
+ "optimizer_config": {},
1012
+ "output_online_normalizer": null,
1013
+ "parallel_inp": [],
1014
+ "phase": 1,
1015
+ "progress_callback": "<cids.tensorflow.callbacks.EpochProgressCallback object at 0x7f6288099c60>",
1016
+ "report_freq": 1,
1017
+ "report_samples_above_threshold": false,
1018
+ "result_dir": "PosixPath('/mnt/data2/yinghanz/codes/frameworks/test/cids/DATA/ex-mnist/RESULTS')",
1019
+ "save_best_only": true,
1020
+ "save_freq": 1,
1021
+ "states": [],
1022
+ "strategy": "<tensorflow.python.distribute.one_device_strategy.OneDeviceStrategy object at 0x7f61cc6667d0>",
1023
+ "suppress_architecture_string": false
1024
+ }
1025
+ },
1026
+ "model_hyper_parameters": {
1027
+ "dropout": 0.3,
1028
+ "num_kernels": 64
1029
+ }
1030
+ }
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/plot/input_preprocess_model.png ADDED
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/plot/model.png ADDED
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/plot/output_preprocess_model.png ADDED
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/plot/postprocess_model.png ADDED
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/summary/train/events.out.tfevents.1721741561.mms-hgx-01.3272949.0.v2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:747558fc11b7ce8dbc67601ce4a501b0c07e2cca0660f53095810121b87038ce
3
+ size 18176
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/summary/train/events.out.tfevents.1721741652.mms-hgx-01.3272949.2.v2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b5f38b22371479319f8c5aa0670513a8ef08683bc98b8f60ee9ae0484196bc1
3
+ size 363720
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/summary/validation/events.out.tfevents.1721741642.mms-hgx-01.3272949.1.v2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73e66cc864a608136dfd0d3715bd911fe56bd3c974c8c2fb7633830be2471b82
3
+ size 356
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/summary/validation/events.out.tfevents.1721741685.mms-hgx-01.3272949.3.v2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:312a9518eef31e7569abc44cd8d39937a244067320c132ba1fff7269d8ada351
3
+ size 6440
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/train_results_phase00.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "train_loss": 0.31650257110595703,
3
+ "training_history": {
4
+ "accuracy": [
5
+ 0.9023571610450745
6
+ ],
7
+ "epochs": [
8
+ 0
9
+ ],
10
+ "loss": [
11
+ 0.31650257110595703
12
+ ],
13
+ "val_accuracy": [
14
+ 0.11577777564525604
15
+ ],
16
+ "val_loss": [
17
+ 3.1068718433380127
18
+ ]
19
+ },
20
+ "training_hyper_parameters": {
21
+ "batch_size": 256,
22
+ "count": 1,
23
+ "freeze": false,
24
+ "learning_rate": 0.0001
25
+ },
26
+ "training_schedule": {
27
+ "batch_size": 256,
28
+ "count": [
29
+ 1,
30
+ 21
31
+ ],
32
+ "freeze": [
33
+ false,
34
+ true
35
+ ],
36
+ "learning_rate": 0.0001
37
+ },
38
+ "valid_loss": 3.1068718433380127,
39
+ "valid_loss_best": 3.1068718433380127
40
+ }
DATA/ex-mnist/RESULTS/mnist--image--label--onehot/mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10/train_results_phase01.json ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "train_loss": 0.00522185955196619,
3
+ "training_history": {
4
+ "accuracy": [
5
+ 0.9784761667251587,
6
+ 0.9843571186065674,
7
+ 0.9906428456306458,
8
+ 0.9923095107078552,
9
+ 0.9955238103866577,
10
+ 0.9968809485435486,
11
+ 0.9975476264953613,
12
+ 0.9981666803359985,
13
+ 0.9975952506065369,
14
+ 0.9983333349227905,
15
+ 0.9991428852081299,
16
+ 0.9989285469055176,
17
+ 0.9990476369857788,
18
+ 0.9991190433502197,
19
+ 0.9983571171760559,
20
+ 0.9989285469055176,
21
+ 0.9992142915725708,
22
+ 0.9988095164299011,
23
+ 0.9982380867004395,
24
+ 0.9982380867004395
25
+ ],
26
+ "epochs": [
27
+ 1,
28
+ 2,
29
+ 3,
30
+ 4,
31
+ 5,
32
+ 6,
33
+ 7,
34
+ 8,
35
+ 9,
36
+ 10,
37
+ 11,
38
+ 12,
39
+ 13,
40
+ 14,
41
+ 15,
42
+ 16,
43
+ 17,
44
+ 18,
45
+ 19,
46
+ 20
47
+ ],
48
+ "loss": [
49
+ 0.06971294432878494,
50
+ 0.05041918531060219,
51
+ 0.030148645862936974,
52
+ 0.023643067106604576,
53
+ 0.015391252934932709,
54
+ 0.01150449551641941,
55
+ 0.008600329980254173,
56
+ 0.00657573901116848,
57
+ 0.007610897067934275,
58
+ 0.005366459954530001,
59
+ 0.0037362119182944298,
60
+ 0.003925640136003494,
61
+ 0.003741362364962697,
62
+ 0.0032922206446528435,
63
+ 0.004701800178736448,
64
+ 0.0035386420786380768,
65
+ 0.0027312927413731813,
66
+ 0.0041613285429775715,
67
+ 0.005273973569273949,
68
+ 0.00522185955196619
69
+ ],
70
+ "val_accuracy": [
71
+ 0.14677777886390686,
72
+ 0.8572221994400024,
73
+ 0.9821110963821411,
74
+ 0.9874444603919983,
75
+ 0.9871110916137695,
76
+ 0.9877777695655823,
77
+ 0.9897778034210205,
78
+ 0.9896666407585144,
79
+ 0.9897778034210205,
80
+ 0.9897778034210205,
81
+ 0.9904444217681885,
82
+ 0.9894444346427917,
83
+ 0.988111138343811,
84
+ 0.988111138343811,
85
+ 0.9915555715560913,
86
+ 0.9902222156524658,
87
+ 0.9898889064788818,
88
+ 0.9900000095367432,
89
+ 0.9896666407585144,
90
+ 0.9890000224113464
91
+ ],
92
+ "val_loss": [
93
+ 3.057567596435547,
94
+ 0.39954081177711487,
95
+ 0.06208071485161781,
96
+ 0.038617074489593506,
97
+ 0.03684410825371742,
98
+ 0.03806221857666969,
99
+ 0.033092863857746124,
100
+ 0.03563697636127472,
101
+ 0.032770559191703796,
102
+ 0.03400570526719093,
103
+ 0.033928826451301575,
104
+ 0.03663121536374092,
105
+ 0.03895076364278793,
106
+ 0.042693354189395905,
107
+ 0.031171562150120735,
108
+ 0.035896580666303635,
109
+ 0.03794649988412857,
110
+ 0.039908986538648605,
111
+ 0.04449998587369919,
112
+ 0.04104391485452652
113
+ ]
114
+ },
115
+ "training_hyper_parameters": {
116
+ "batch_size": 256,
117
+ "count": 21,
118
+ "freeze": true,
119
+ "learning_rate": 0.0001
120
+ },
121
+ "training_schedule": {
122
+ "batch_size": 256,
123
+ "count": [
124
+ 1,
125
+ 21
126
+ ],
127
+ "freeze": [
128
+ false,
129
+ true
130
+ ],
131
+ "learning_rate": 0.0001
132
+ },
133
+ "valid_loss": 0.04104391485452652,
134
+ "valid_loss_best": 0.031171562150120735
135
+ }
DATA/ex-mnist/project_ex-mnist.json ADDED
The diff for this file is too large to render. See raw diff
 
README.md CHANGED
@@ -1,12 +1,14 @@
1
  ---
2
- title: Mnist Cids
3
- emoji: 🐢
4
- colorFrom: blue
5
- colorTo: blue
6
  sdk: gradio
7
  sdk_version: 4.39.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: MNIST-CIDS
3
+ emoji: 😻
4
+ colorFrom: red
5
+ colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 4.39.0
8
  app_file: app.py
9
  pinned: false
10
+ python_version: 3.10.6
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
14
+
app.py ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import cv2 as cv
3
+ from urllib.request import urlretrieve
4
+ import gradio as gr
5
+ import matplotlib.pyplot as plt
6
+
7
+ # urlretrieve("https://github.com/AyaanZaveri/mnist/raw/main/mnist-model.h5", "mnist-model.h5")
8
+
9
+ # model = tf.keras.models.load_model("mnist-model.h5")
10
+
11
+
12
+ import os
13
+
14
+ os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
15
+ os.environ["TF_FORCE_GPU_ALLOW_GROWTH"] = "true"
16
+
17
+ import cids
18
+
19
+ import numpy as np
20
+ import tensorflow as tf
21
+ import seaborn as sns
22
+
23
+ from pathlib import Path
24
+ from tensorflow.keras import layers as klayers
25
+ from cids.tensorflow import layers as clayers
26
+ from cids.tensorflow.tuner import SearchResults
27
+ from cids.statistics import metrics
28
+ from kadi_ai import KadiAIProject
29
+ from matplotlib import pyplot as plt
30
+ from kerastuner import HyperParameters
31
+
32
+
33
+ ################################################################################
34
+ # Controls
35
+
36
+ CHECK = False
37
+ SEARCH = False
38
+ USE_BEST_SEARCH_CONFIG = False
39
+ TRAIN = False
40
+ EVAL = True
41
+ PLOT = False
42
+ ANALYZE = False
43
+
44
+ TRAIN_CONTINUE = False
45
+
46
+
47
+ num_check_samples = 100
48
+ num_plot_samples = 20
49
+ num_principal_components = 3
50
+
51
+
52
+ ################################################################################
53
+ # Data paths
54
+
55
+ project_name = "ex-mnist"
56
+ project_dir = Path.cwd() / "DATA" / project_name
57
+ project = KadiAIProject(project_name, root=project_dir)
58
+
59
+ # Read paths
60
+ # train_samples, valid_samples, test_samples = project.get_split_datasets(
61
+ # shuffle=True, valid_split=0.15, test_split=0.15
62
+ # )
63
+
64
+ test_samples = ["./DATA/ex-mnist/INPUTS/tfrecord/sample29579.tfrecord"]
65
+
66
+
67
+
68
+ ################################################################################
69
+ # Data definition
70
+
71
+ data_definition = project.data_definition
72
+ data_definition.input_features = ["image"]
73
+ data_definition.output_features = ["label"]
74
+
75
+
76
+ ################################################################################
77
+ # Neural network
78
+
79
+ # Model
80
+ def model_function(hp, data_definition):
81
+
82
+ # Hyper parameters
83
+ num_kernels = hp.Choice("num_kernels", [32, 64, 128, 256, 512], default=64)
84
+ dropout_rate = hp.Float("dropout", 0.0, 0.7, default=0.3) # not used
85
+
86
+ # Ref: https://github.com/AyaanZaveri/mnist/blob/main/MNIST_Number.ipynb
87
+ layers = []
88
+ layers.append(klayers.Conv2D(num_kernels, (3, 3), strides=(1, 1), padding="same"))
89
+ layers.append(klayers.ReLU())
90
+ layers.append(klayers.Conv2D(num_kernels, (3, 3), strides=(1, 1), padding="same"))
91
+ layers.append(klayers.ReLU())
92
+ # layers.append(klayers.Dropout(dropout_rate))
93
+ layers.append(klayers.MaxPooling2D(pool_size=(2, 2)))
94
+ layers.append(klayers.BatchNormalization())
95
+
96
+ layers.append(klayers.Conv2D(num_kernels*2, (3, 3), strides=(1, 1), padding="same"))
97
+ layers.append(klayers.ReLU())
98
+ layers.append(klayers.Conv2D(num_kernels*2, (3, 3), strides=(1, 1), padding="same"))
99
+ layers.append(klayers.ReLU())
100
+
101
+ layers.append(klayers.MaxPooling2D(pool_size=(2, 2)))
102
+ layers.append(klayers.BatchNormalization())
103
+
104
+ layers.append(klayers.Conv2D(num_kernels*4, (3, 3), strides=(1, 1), padding="same"))
105
+ layers.append(klayers.MaxPooling2D(pool_size=(2, 2)))
106
+
107
+ layers.append(klayers.Flatten())
108
+ layers.append(klayers.Dropout(dropout_rate))
109
+ layers.append(klayers.Dense(512))
110
+ layers.append(klayers.Dense(10, activation="softmax"))
111
+ return tf.keras.Sequential(layers)
112
+
113
+
114
+ # Set a model name
115
+ model_name = "mnist"
116
+ model_name += "--" + "--".join(
117
+ [
118
+ "+".join(list(data_definition.input_features)),
119
+ "+".join(list(data_definition.output_features)),
120
+ ]
121
+ )
122
+ model_name += "--onehot"
123
+
124
+ saved_model_name = "mnist--image--label--onehot-default-64C3-64C3-MP2-128C3-128C3-MP2-256C3-MP2-512-10"
125
+
126
+ model = cids.CIDSModel.categorical_classification(
127
+ 10,
128
+ data_definition,
129
+ model_function,
130
+ name=model_name,
131
+ identifier="default", # or "best"
132
+ result_dir=project.result_dir,
133
+ )
134
+ model.encode_categorical = "outputs"
135
+ model.metrics.append("accuracy")
136
+ model.monitor = "val_accuracy"
137
+ model.online_normalize = False
138
+ model.data_reader.prefetch = "cache"
139
+
140
+ # Load hp
141
+ import json
142
+ hp_path = os.path.join(model.base_model_dir, saved_model_name, "hp.json")
143
+ print("hp path", hp_path)
144
+ with open(hp_path, "r") as f:
145
+ saved_config = json.load(f)
146
+ hp = HyperParameters.from_config(saved_config)
147
+
148
+
149
+ if EVAL:
150
+ project.log(">> Evaluating...")
151
+ project.log(">>> Metrics...")
152
+ # Compute predictions
153
+ # test_loss = model.eval_data(
154
+ # test_samples, batch_size=4, checkpoint="last", hp=hp, submodels="generator")
155
+ print("hp", hp.values)
156
+ X, Y, Y_ = model.infer_data(
157
+ test_samples,
158
+ batch_size=4,
159
+ checkpoint="last",
160
+ hp=hp,
161
+ )
162
+
163
+ model = model.core_model
164
+
165
+ def recognize_digit(image):
166
+ image = cv.resize(image["composite"][:,:,-1], (28, 28))
167
+ # For debug, find out which chanel
168
+ # from PIL import Image
169
+ # for i in range(images["composite"].shape[-1]):
170
+ # image = images["composite"][:,:,i]
171
+ # im = Image.fromarray(image)
172
+ # im.save(f"c{i}.png")
173
+ # for i in range(images["background"].shape[-1]):
174
+ # image = images["background"][:,:,i]
175
+ # im = Image.fromarray(image)
176
+ # im.save(f"b{i}.png")
177
+ # print(image.shape)
178
+ # # image = image / 255
179
+ # # plt.imshow(image)
180
+
181
+ #from PIL import Image
182
+ #im = Image.fromarray(image)
183
+ #im.save(f"saved.png")
184
+
185
+ # image = image / 255
186
+ #print("max", image.max())
187
+ image = (image - 127.5) / 127.5
188
+ image = image.reshape((1, 28, 28))
189
+ prediction = model.predict(image)
190
+
191
+ prediction = model.predict(image).tolist()[0]
192
+ return {str(i): prediction[i] for i in range(10)}
193
+
194
+ gr.Interface(fn=recognize_digit,
195
+ inputs="sketchpad",
196
+ outputs=gr.Label(num_top_classes=3),
197
+ live=True,
198
+ css=".footer {display:none !important}",
199
+ # title="MNIST Sketchpad",
200
+ description="A simple model trained on MNIST dataset using CIDS framework.\nDraw a single digit (0-9) in the center of the canvas.").launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ git+https://gitlab.com/intelligent-analysis/cids.git@develop
2
+ opencv-python
3
+ numpy==1.26