Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
logs/
results/
prj/
__pycache__/
94 changes: 68 additions & 26 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
---

experiment:
seed: 42
save_dir: ./results
save_model: model
gpus: [0]
save_dir: ./prj/exp_mnist_bayes_lenet_try
save_model: mnist_bayes_lenet_10samples_mc
cpu: True
ckpt_file: best_chkp.tf

dataset:
name: mnist
data: <dict>
mean: 0.0
std: 1.0

model:
original: <obj>
Expand All @@ -21,54 +24,93 @@ model:
dropout_type: mc
num_bayes_layer: 3

# NOTE: introduce typing so that we can type dictionaries too
S1:
accuracy:
weight: 0.25
base: 0.99
ece:
weight: -0.25
base: 0.03
ape:
weight: 0.25
base: 1.5
flops:
weight: -0.25
base: 5340192

top_n: 3
# special metric calculated from the other metrics
top_metric: score

name: Balance

S2:
accuracy:
weight: 0.75
base: 0.99
ece:
weight: 0.00
base: 0.03
ape:
weight: 0.00
base: 1.5
flops:
weight: -0.25
base: 5340192

top_n: 1
top_metric: flops

name: Opt-Efficiency

strategy:
strategies: [ S1 ]
curr_strategy: <int>
curr_results: ((bayes_opt.summary))

terminate_strategies: <bool>
results: <dict>
save_dir: ((experiment.save_dir))


bayes_opt:
iteration: <int>
terminate: <bool>
engine: <obj>
score: <float>
summary: <list>

curr_strategy: <obj>

control:
params: dict
metrics: dict
suggests: dict

num_iter: 3
num_iter: 2
seed: ((experiment.seed))
tunable:
dropout_rate:
value: ((model.dropout_rate))
space: [0.1, 0.2, 0.3, 0.4]
space: [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.80, 0.85, 0.90, 0.95]
# space: [0.1, 0.2, 0.3, 0.4]
p_rate:
value: ((model.p_rate))
space: [0.0, 0.1, 0.2]
space: [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.80, 0.85, 0.90, 0.95]
# space: [0.0, 0.1, 0.2]
num_bayes_layer:
value: ((model.num_bayes_layer))
space: [1, 2, 3]
scale_factor:
value: ((model.scale_factor))
space: [0.5, 1.0, 1.5]
# space: [0.5, 1.0, 1.5]
space: [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.80, 0.85, 0.90, 0.95]

metrics:
accuracy: ((eval.accuracy))
ece: ((eval.ece))
aPE: ((eval.ape))
FLOP: ((eval.flop))

score_weights:
accuracy:
weight: 0.25
base: 0.99
ece:
weight: 0.25
base: -0.03
aPE:
weight: 0.25
base: 1.5
FLOP:
weight: 0.25
base: -5340192

ape: ((eval.ape))
flops: ((eval.flops))

train:
optimizer: <obj>
Expand All @@ -82,7 +124,7 @@ eval:
ece: <float>
ape: <float>
accuracy: <float>
flop: <float>
flops: <float>

mc_samples: 5
num_eval_images: 200
Expand Down
145 changes: 145 additions & 0 deletions config_resnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
---

experiment:
seed: 42
save_dir: ./prj/exp_cifar_bayes_resnet
save_model: cifar_resnet_tmp_3bayeslayer_mc
gpus: [0, 1]
ckpt_file: best_chkp.tf

dataset:
name: cifar10
data: <dict>
mean: 0.0
std: 1.0

model:
original: <obj>
logic: <obj>
name: resnet
is_quant: false
dropout_rate: 0.4
p_rate: 0.05
scale_factor: 0.3
dropout_type: mc
num_bayes_layer: 3

# NOTE: introduce typing so that we can type dictionaries too
S1:
accuracy:
weight: 0.25
base: 0.99
ece:
weight: -0.25
base: 0.03
ape:
weight: 0.25
base: 1.5
flops:
weight: -0.25
base: 5340192

top_n: 3
# special metric calculated from the other metrics
top_metric: score

name: Balance

S2:
accuracy:
weight: 0.75
base: 0.99
ece:
weight: 0.00
base: 0.03
ape:
weight: 0.00
base: 1.5
flops:
weight: -0.25
base: 5340192

top_n: 1
top_metric: flops

name: Opt-Efficiency

strategy:
strategies: [ S1 ]
curr_strategy: <int>
curr_results: ((bayes_opt.summary))

terminate_strategies: <bool>
results: <dict>
save_dir: ((experiment.save_dir))


bayes_opt:
iteration: <int>
terminate: <bool>
engine: <obj>
score: <float>
summary: <list>

curr_strategy: <obj>

control:
params: dict
suggests: dict

num_iter: 2
seed: ((experiment.seed))
tunable:
dropout_rate:
value: ((model.dropout_rate))
space: [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.80, 0.85, 0.90, 0.95]
# space: [0.1, 0.2, 0.3, 0.4]
p_rate:
value: ((model.p_rate))
space: [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.80, 0.85, 0.90, 0.95]
# space: [0.0, 0.1, 0.2]
num_bayes_layer:
value: ((model.num_bayes_layer))
space: [1, 2, 3]
scale_factor:
value: ((model.scale_factor))
# space: [0.5, 1.0, 1.5]
space: [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.80, 0.85, 0.90, 0.95]

metrics:
accuracy: ((eval.accuracy))
ece: ((eval.ece))
ape: ((eval.ape))
flops: ((eval.flops))

train:
optimizer: <obj>
id: ((bayes_opt.iteration))
num_epoch: 3
batch_size: 128
learning_rate: 0.01
validation_split: 0.1

eval:
ece: <float>
ape: <float>
accuracy: <float>
flops: <float>

mc_samples: 10
num_eval_images: 200
num_bins: 10


reporter:
log:
- bayes_opt.iteration
- dropout_rate_list
- p_rate
- num_bayes_layer
- scale_factor
- accuracy
- flops
- ece
- ape
- score
3 changes: 3 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ dependencies:
- tensorflow=2.12
- nvidia/label/cuda-11.8.0::cuda-nvcc
- nvidia/label/cuda-11.8.0::cuda-toolkit
- matplotlib=3.7
- seaborn=0.13.2
- numpy<1.24
- pip
- pip:
- -r requirements.txt
Expand Down
8 changes: 0 additions & 8 deletions logic/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,6 @@ def on_epoch_end(self, epoch, logs=None):

callbacks.append(PrintEpochCallback())



logger.info(f"p_rate: {cfg.model.p_rate}")
logger.info(f"batch_size: {cfg.training.batch_size}")
logger.info(f"num_epoch: {cfg.training.num_epoch}")
logger.debug(f"validation_split: {cfg.training.validation_split}")


def hash_model(model):
import hashlib
import json
Expand Down
11 changes: 11 additions & 0 deletions nautic/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Config structure for the flowx
class FlowxConfig:
disable_nautic: bool = False

flowx_cfg = FlowxConfig()

# Config structure for the taskx
class TaskxConfig:
disable_nautic: bool = False

taskx_cfg = TaskxConfig()
Loading