diff --git a/README.adoc b/README.adoc index 9f6a7ff2..1ee97009 100644 --- a/README.adoc +++ b/README.adoc @@ -710,6 +710,7 @@ Here is a list of all command line arguments: --model_save_mode, Model save mode. Can be 'replace' or 'append'. Defaults to 'replace'. --cache_mode, Cache mode. Can be 'none', 'load' or 'save'. Defaults to 'none'. --cache_file, Path to cache file. Defaults to 'train_cache.npz'. +--threads, Number of CPU threads. --fmin and --fmax, Minimum and maximum frequency for bandpass filter. Defaults to 0 and 15000. --autotune, Whether to use automatic hyperparameter tuning (this will execute multiple training runs to search for optimal hyperparameters). --autotune_trials, Number of training runs for hyperparameter tuning. Defaults to 50. diff --git a/analyze.py b/analyze.py index 0dbbe8e7..bb7a3f8f 100644 --- a/analyze.py +++ b/analyze.py @@ -477,7 +477,7 @@ def analyzeFile(item): default=None, help="Path to combined Raven selection table. If set and rtype is 'table', all results will be combined into this file. Defaults to None." ) - parser.add_argument("--threads", type=int, default=multiprocessing.cpu_count() // 2, help="Number of CPU threads.") + parser.add_argument("--threads", type=int, default=min(8, max(1, multiprocessing.cpu_count() // 2)), help="Number of CPU threads.") parser.add_argument( "--batchsize", type=int, default=1, help="Number of samples to process at the same time. Defaults to 1." ) diff --git a/config.py b/config.py index 7639bbc1..ea50cf4f 100644 --- a/config.py +++ b/config.py @@ -3,7 +3,7 @@ ################# # GUI version -GUI_VERSION: str = "1.0-beta" +GUI_VERSION: str = "1.0.1-beta1" # Random seed for gaussian noise RANDOM_SEED: int = 42 diff --git a/train.py b/train.py index 2c565769..b5768053 100644 --- a/train.py +++ b/train.py @@ -368,6 +368,7 @@ def run_trial(self, trial, *args, **kwargs): parser.add_argument("--model_save_mode", default="replace", help="Model save mode. Can be 'replace' or 'append', where 'replace' will overwrite the original classification layer and 'append' will combine the original classification layer with the new one. Defaults to 'replace'.") parser.add_argument("--cache_mode", default="none", help="Cache mode. Can be 'none', 'load' or 'save'. Defaults to 'none'.") parser.add_argument("--cache_file", default="train_cache.npz", help="Path to cache file. Defaults to 'train_cache.npz'.") + parser.add_argument("--threads", type=int, default=min(8, max(1, multiprocessing.cpu_count() // 2)), help="Number of CPU threads.") parser.add_argument("--fmin", type=int, default=cfg.SIG_FMIN, help="Minimum frequency for bandpass filter in Hz. Defaults to {} Hz.".format(cfg.SIG_FMIN)) parser.add_argument("--fmax", type=int, default=cfg.SIG_FMAX, help="Maximum frequency for bandpass filter in Hz. Defaults to {} Hz.".format(cfg.SIG_FMAX)) @@ -397,7 +398,7 @@ def run_trial(self, trial, *args, **kwargs): cfg.TRAIN_CACHE_MODE = args.cache_mode.lower() cfg.TRAIN_CACHE_FILE = args.cache_file cfg.TFLITE_THREADS = 1 - cfg.CPU_THREADS = max(1, multiprocessing.cpu_count() - 1) # let's use everything we have (well, almost) + cfg.CPU_THREADS = cfg.CPU_THREADS = max(1, int(args.threads)) cfg.BANDPASS_FMIN = max(0, min(cfg.SIG_FMAX, int(args.fmin))) cfg.BANDPASS_FMAX = max(cfg.SIG_FMIN, min(cfg.SIG_FMAX, int(args.fmax)))