Training Loop Example
Train
Bases: ABC
Abstract class defining what should be the major steps of a training loop.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ABC |
class
|
Abstract Class |
required |
Source code in azure_helper/steps/train.py
TrainingLoopExample
Bases: Train
Source code in azure_helper/steps/train.py
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
__init__(run, trainig_datastore, model_name, target_name, project_name)
Typical example of how you could define a training loop to be used in the ScriptRunConfig
class in the
submit_run method.
you can use it in the following way.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run |
Run
|
The run corresponding to your Experiment. |
required |
trainig_datastore |
str
|
The name of the datastore where you fetch your datasets. |
required |
model_name |
str
|
The name of the model you train. |
required |
target_name |
str
|
The name of the target, in your dataset. |
required |
project_name |
str
|
The name of the project you're working on. |
required |
Source code in azure_helper/steps/train.py
get_df_from_datastore_path(datastore, datastore_path)
Utils function to fetch your datas from a datastore.
Note that this function is different from download_blob_to_df
method.
BlobStorageInterface.download_blob_to_df
takes datas from a blob in one of your container located in your
storage account. We are fetching datas here from a datastore, which is a registered blob in yout AZML workspace.
Obviously, using get_df_from_datastore_path
on a Datastore or using BlobStorageInterface.download_blob_to_df
on the blob corresponding to the Datastore will get you the same result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datastore |
Datastore
|
The name of the registered Datastore in your AZML workspace. |
required |
datastore_path |
str
|
The path to the datas you're fetching. |
required |
Returns:
Type | Description |
---|---|
pd.DataFrame
|
The fetched datas as a dataframe. |
Source code in azure_helper/steps/train.py
prepare_data()
Get all your datas (train, test) at once.
Returns:
Type | Description |
---|---|
List[pd.DataFrame]
|
List[pd.DataFrame]: Your datas. |
Source code in azure_helper/steps/train.py
train_model(x_train, y_train)
Start the training of the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_train |
pd.DataFrame
|
Train dataset. |
required |
y_train |
pd.DataFrame
|
Train target. |
required |
Returns:
Name | Type | Description |
---|---|---|
_type_ | A trained model. |
Source code in azure_helper/steps/train.py
evaluate_model(model, x_test, y_test)
Evaluate your model and record the corresponding metric.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
_type_
|
The model you want to evaluate. |
required |
x_test |
pd.DataFrame
|
Test/Validation dataset. |
required |
y_test |
pd.DataFrame
|
Test/Validation target. |
required |
Source code in azure_helper/steps/train.py
save_model(model)
Convert the model to ONNX and save it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
_type_
|
Your trained model. |
required |
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
The path where your converted model is located. |
Source code in azure_helper/steps/train.py
register_model(model_path)
Register your model into your AZML Model Registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_path |
Path
|
The path returned by the function |
required |