diff --git a/fluid/ce_demo/mnist/.run_ce.sh b/fluid/ce_demo/mnist/.run_ce.sh new file mode 100755 index 0000000000000000000000000000000000000000..d6ccf429b52da1ff26ac02df5af287461a823a98 --- /dev/null +++ b/fluid/ce_demo/mnist/.run_ce.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# This file is only used for continuous evaluation. + +rm -rf *_factor.txt +model_file='model.py' +python $model_file --batch_size 128 --pass_num 5 --device CPU | python _ce.py diff --git a/fluid/ce_demo/mnist/_ce.py b/fluid/ce_demo/mnist/_ce.py new file mode 100644 index 0000000000000000000000000000000000000000..0bc4b02ba535e7687bfc6efd428653c3f791d8f9 --- /dev/null +++ b/fluid/ce_demo/mnist/_ce.py @@ -0,0 +1,58 @@ +# this file is only used for continuous evaluation test! + +import os +import sys +sys.path.append(os.environ['ceroot']) +from kpi import CostKpi, DurationKpi, AccKpi + +# NOTE kpi.py should shared in models in some way!!!! + +train_cost_kpi = CostKpi('train_cost', 0.02, actived=True) +test_acc_kpi = AccKpi('test_acc', 0.005, actived=True) +train_duration_kpi = DurationKpi('train_duration', 0.06, actived=True) +train_acc_kpi = AccKpi('train_acc', 0.005, actived=True) + +tracking_kpis = [ + train_acc_kpi, + train_cost_kpi, + test_acc_kpi, + train_duration_kpi, +] + +def parse_log(log): + ''' + This method should be implemented by model developers. + + The suggestion: + + each line in the log should be key, value, for example: + + " + train_cost\t1.0 + test_cost\t1.0 + train_cost\t1.0 + train_cost\t1.0 + train_acc\t1.2 + " + ''' + for line in log.split(): + fs = line.strip().split('\t') + if len(fs) == 2: + kpi_name = fs[0] + kpi_value = float(fs[1]) + yield kpi_name, kpi_value + + +def log_to_ce(log): + kpi_tracker = {} + for kpi in tracking_kpis: + kpi_tracker[kpi.name] = kpi + + for (kpi_name, kpi_value) in parse_log(log): + kpi_tracker[kpi_name].add_record(kpi_value) + + +if __name__ == '__main__': + log = sys.stdin.read() + log_to_ce(log) + diff --git a/fluid/mnist/model.py b/fluid/ce_demo/mnist/model.py similarity index 100% rename from fluid/mnist/model.py rename to fluid/ce_demo/mnist/model.py diff --git a/fluid/ce_demo/mnist_directory_in_ce/latest_kpis/some_kpi.txt b/fluid/ce_demo/mnist_directory_in_ce/latest_kpis/some_kpi.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/fluid/ce_demo/mnist_directory_in_ce/run.xsh b/fluid/ce_demo/mnist_directory_in_ce/run.xsh new file mode 100755 index 0000000000000000000000000000000000000000..0ea19f9d71e211bd545cd84cdeff687af1667f53 --- /dev/null +++ b/fluid/ce_demo/mnist_directory_in_ce/run.xsh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd $mnist_model_in_models + +./.run_ce.sh diff --git a/fluid/mnist/.run.sh b/fluid/mnist/.run.sh deleted file mode 100755 index ec798ccec9f7d619534b79e6786996125245e2b1..0000000000000000000000000000000000000000 --- a/fluid/mnist/.run.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -rm -rf *_factor.txt -model_file='model.py' -python $model_file --batch_size 128 --pass_num 5 --device CPU