raytune_parser ¶
Ray Tune results parser for extracting and saving best model configurations and weights.
Classes:
-
RayTuneMetrics
–TypedDict for storing Ray Tune metrics results.
-
RayTuneOptimizer
–TypedDict for storing Ray Tune optimizer state.
-
RayTuneResult
–TypedDict for storing Ray Tune optimization results.
-
TuneParser
–Parser class for Ray Tune results to extract best configurations and model weights.
TuneParser ¶
TuneParser(result: ResultGrid)
Parser class for Ray Tune results to extract best configurations and model weights.
Methods:
-
fix_config_values
–Correct config values.
-
get_best_config
–Get the best config from the results.
-
get_best_model
–Get the best model weights from the results.
-
get_best_optimizer
–Get the best optimizer state from the results.
-
save_best_config
–Save the best config to a file.
-
save_best_metrics_dataframe
–Save the dataframe with the metrics at each iteration of the best sample to a file.
-
save_best_model
–Save the best model weights to a file.
-
save_best_optimizer
–Save the best optimizer state to a file.
Source code in src/stimulus/learner/raytune_parser.py
39 40 41 42 |
|
fix_config_values ¶
Correct config values.
This method modifies the configuration dictionary to remove or convert non-serializable objects (such as Ray ObjectRefs) so that the entire dictionary can be safely dumped to a YAML file.
Parameters:
Returns:
Source code in src/stimulus/learner/raytune_parser.py
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 |
|
get_best_config ¶
Get the best config from the results.
Returns:
Raises:
-
ValueError
–If the config is missing.
Source code in src/stimulus/learner/raytune_parser.py
60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
get_best_model ¶
Get the best model weights from the results.
Returns:
Raises:
-
ValueError
–If the checkpoint is missing.
Source code in src/stimulus/learner/raytune_parser.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
get_best_optimizer ¶
Get the best optimizer state from the results.
Returns:
Raises:
-
ValueError
–If the checkpoint is missing.
Source code in src/stimulus/learner/raytune_parser.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
save_best_config ¶
save_best_config(output: str) -> None
Save the best config to a file.
Todo
maybe only save the relevant config values.
Parameters:
-
output
(str
) –File path to save the configuration.
Source code in src/stimulus/learner/raytune_parser.py
74 75 76 77 78 79 80 81 82 83 84 85 |
|
save_best_metrics_dataframe ¶
save_best_metrics_dataframe(output: str) -> None
Save the dataframe with the metrics at each iteration of the best sample to a file.
Parameters:
-
output
(str
) –CSV file path to save the metrics.
Source code in src/stimulus/learner/raytune_parser.py
116 117 118 119 120 121 122 123 |
|
save_best_model ¶
save_best_model(output: str) -> None
Save the best model weights to a file.
This method retrieves the best model weights using the get_best_model helper which loads the model data from the checkpoint's directory, then re-saves it using safe_save_file.
Parameters:
-
output
(str
) –Path where the best model weights will be saved.
Source code in src/stimulus/learner/raytune_parser.py
140 141 142 143 144 145 146 147 148 149 150 151 |
|
save_best_optimizer ¶
save_best_optimizer(output: str) -> None
Save the best optimizer state to a file.
Parameters:
-
output
(str
) –Path where the best optimizer state will be saved.
Source code in src/stimulus/learner/raytune_parser.py
168 169 170 171 172 173 174 175 |
|