Optimizer
Optimizer
#
Base class. Implements all low-level functionality.
Parameters:
-
name
(str
, default:None
) –Name of the subdirectory inside path where model will be saved. The final model directory will be os.path.join(path, name) If None, defaults to the model's class name: self.class.name
-
path
(str
, default:None
) –Directory location to store all outputs. If None, a new unique time-stamped directory is chosen.
Source code in src/qtt/optimizers/optimizer.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
ante()
#
This method is intended for the use with a tuner. It allows to perform some pre-processing steps before each ask.
ask()
#
load(path, reset_paths=True, verbose=True)
classmethod
#
Loads the model from disk to memory.
Parameters:
-
path
(str
) –Path to the saved model, minus the file name. This should generally be a directory path ending with a '/' character (or appropriate path separator value depending on OS). The model file is typically located in os.path.join(path, cls.model_file_name).
-
reset_paths
(bool
, default:True
) –Whether to reset the self.path value of the loaded model to be equal to path. It is highly recommended to keep this value as True unless accessing the original self.path value is important. If False, the actual valid path and self.path may differ, leading to strange behaviour and potential exceptions if the model needs to load any other files at a later time.
-
verbose
(bool
, default:True
) –Whether to log the location of the loaded file.
Returns:
-
model
(Optimizer
) –The loaded model object.
Source code in src/qtt/optimizers/optimizer.py
post()
#
This method is intended for the use with a tuner. It allows to perform some post-processing steps after each tell.
reset_path(path=None)
#
Reset the path of the model.
Parameters:
-
path
(str
, default:None
) –Directory location to store all outputs. If None, a new unique time-stamped directory is chosen.
Source code in src/qtt/optimizers/optimizer.py
save(path=None, verbose=True)
#
Saves the model to disk.
Parameters:
-
path
(str
, default:None
) –Path to the saved model, minus the file name. This should generally be a directory path ending with a '/' character (or appropriate path separator value depending on OS). If None, self.path is used. The final model file is typically saved to os.path.join(path, self.model_file_name).
-
verbose
(bool
, default:True
) –Whether to log the location of the saved file.
Returns:
-
str
(str
) –Path to the saved model, minus the file name. Use this value to load the model from disk via cls.load(path), where cls is the class of the model object (e.g., model = Model.load(path)).