17
17
import sys
18
18
import math
19
19
import time
20
+ from time import gmtime , strftime
20
21
import numpy as np
21
22
import shutil
22
23
import paddle
40
41
41
42
_logger = get_logger (__name__ , level = logging .INFO )
42
43
43
- SMAC_TMP_FILE_PATTERN = "smac3-output* "
44
+ SMAC_TMP_FILE_PATTERN = "smac3-output_ "
44
45
45
46
46
47
def remove (path ):
@@ -496,14 +497,19 @@ def quant_post_hpo(
496
497
497
498
cs .add_hyperparameters (hyper_params )
498
499
500
+ s_datetime = strftime ("%Y-%m-%d-%H:%M:%S" , gmtime ())
501
+ smac_output_dir = SMAC_TMP_FILE_PATTERN + s_datetime
502
+
499
503
scenario = Scenario ({
500
504
"run_obj" : "quality" , # we optimize quality (alternative runtime)
501
505
"runcount-limit" :
502
506
runcount_limit , # max. number of function evaluations; for this example set to a low number
503
507
"cs" : cs , # configuration space
504
508
"deterministic" : "True" ,
505
509
"limit_resources" : "False" ,
506
- "memory_limit" : 4096 # adapt this to reasonable value for your hardware
510
+ "memory_limit" :
511
+ 4096 , # adapt this to reasonable value for your hardware
512
+ "output_dir" : smac_output_dir # output_dir
507
513
})
508
514
# To optimize, we pass the function to the SMAC-object
509
515
smac = SMAC4HPO (
@@ -523,5 +529,5 @@ def quant_post_hpo(
523
529
inc_value = smac .get_tae_runner ().run (incumbent , 1 )[1 ]
524
530
_logger .info ("Optimized Value: %.8f" % inc_value )
525
531
shutil .rmtree (g_quant_model_cache_path )
526
- remove (SMAC_TMP_FILE_PATTERN )
532
+ remove (smac_output_dir )
527
533
_logger .info ("Quantization completed." )
0 commit comments