Skip to content

Commit 9f0b787

Browse files
authored
Merge pull request #11 from absynthe/fix/connect-02-03
Fix: connect 02 and 03
2 parents 75985c7 + 388b6b6 commit 9f0b787

File tree

3 files changed

+37
-24
lines changed

3 files changed

+37
-24
lines changed

01_preprocessing/data_preprocessing.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
"kernelspec": {
297297
"display_name": "Python 3 (Data Science)",
298298
"language": "python",
299-
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-1:081325390199:image/datascience-1.0"
299+
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:eu-west-1:470317259841:image/datascience-1.0"
300300
},
301301
"language_info": {
302302
"codemirror_mode": {

02_training/training.ipynb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"metadata": {},
4444
"outputs": [],
4545
"source": [
46-
"processed_data_prefix = f'{prefix}/outputs' #prefix generated by data processing module\n",
47-
"processed_data_s3_uri = f's3://{default_bucket}/{processed_data_prefix}'"
46+
"processed_data_s3_uri = f's3://{default_bucket}/{prefix}/outputs'\n",
47+
"model_output_path = f's3://{default_bucket}/{prefix}/outputs/model'"
4848
]
4949
},
5050
{
@@ -147,7 +147,7 @@
147147
" hyperparameter_ranges,\n",
148148
" metric_definitions=metric_definitions,\n",
149149
" objective_type=\"Maximize\",\n",
150-
" max_jobs=6,\n",
150+
" max_jobs=2, # Low because of demo purposes\n",
151151
" max_parallel_jobs=2,\n",
152152
" base_tuning_job_name=\"cv-hpo\",\n",
153153
")\n",
@@ -185,6 +185,22 @@
185185
"\n",
186186
"print(f\"\\nBest model artifact file is uploaded here: {best_model_uri}\")"
187187
]
188+
},
189+
{
190+
"cell_type": "markdown",
191+
"metadata": {},
192+
"source": [
193+
"Copy the best model into the prefix used for this project. Note that's possible to directly reference the tuner's output, as above, but given the modularity of this workshop, the artefacts are copied to a known location in S3."
194+
]
195+
},
196+
{
197+
"cell_type": "code",
198+
"execution_count": null,
199+
"metadata": {},
200+
"outputs": [],
201+
"source": [
202+
"!aws s3 cp {best_model_uri} {model_output_path}/model.tar.gz"
203+
]
188204
}
189205
],
190206
"metadata": {

03_model_evaluation/model-evaluation-processing-job.ipynb

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,11 @@
9696
"metadata": {},
9797
"outputs": [],
9898
"source": [
99-
"s3_client = boto3.client('s3')\n",
100-
"model_dir = s3_client.list_objects_v2(Bucket=bucket, Delimiter='/', Prefix=f'{prefix}/{prefix}')['CommonPrefixes'][-1]['Prefix']\n",
101-
"\n",
10299
"s3_images = f's3://{bucket}/{prefix}/outputs/test/'\n",
103100
"s3_manifest = f's3://{bucket}/{prefix}/outputs/manifest'\n",
104-
"s3_model = f's3://{bucket}/{model_dir}output'\n",
101+
"s3_model = f's3://{bucket}/{prefix}/outputs/model/'\n",
105102
"\n",
106-
"print(f's3_images: {s3_images},\\n s3_manifest: {s3_manifest},\\n s3_model: {s3_model}')"
103+
"print(f's3_images: {s3_images},\\ns3_manifest: {s3_manifest},\\ns3_model: {s3_model}')"
107104
]
108105
},
109106
{
@@ -281,20 +278,20 @@
281278
"outputs": [],
282279
"source": [
283280
"script_processor.run(\n",
284-
" code='evaluation.py',\n",
285-
" arguments=[\"--model-file\", \"model.tar.gz\"],\n",
286-
" inputs=[ProcessingInput(source=s3_images, \n",
287-
" destination=\"/opt/ml/processing/input/test\"),\n",
288-
" ProcessingInput(source=s3_manifest, \n",
289-
" destination=\"/opt/ml/processing/input/manifest\"),\n",
290-
" ProcessingInput(source=s3_model, \n",
291-
" destination=\"/opt/ml/processing/model\"),\n",
292-
" ],\n",
293-
" outputs=[\n",
294-
" ProcessingOutput(output_name=\"evaluation\", source=\"/opt/ml/processing/evaluation\", \n",
295-
" destination=s3_evaluation_output),\n",
296-
" ]\n",
297-
" )"
281+
" code='evaluation.py',\n",
282+
" arguments=[\"--model-file\", \"model.tar.gz\"],\n",
283+
" inputs=[ProcessingInput(source=s3_images, \n",
284+
" destination=\"/opt/ml/processing/input/test\"),\n",
285+
" ProcessingInput(source=s3_manifest, \n",
286+
" destination=\"/opt/ml/processing/input/manifest\"),\n",
287+
" ProcessingInput(source=s3_model, \n",
288+
" destination=\"/opt/ml/processing/model\"),\n",
289+
" ],\n",
290+
" outputs=[\n",
291+
" ProcessingOutput(output_name=\"evaluation\", source=\"/opt/ml/processing/evaluation\", \n",
292+
" destination=s3_evaluation_output),\n",
293+
" ]\n",
294+
")"
298295
]
299296
},
300297
{
@@ -359,7 +356,7 @@
359356
"kernelspec": {
360357
"display_name": "Python 3 (Data Science)",
361358
"language": "python",
362-
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-1:081325390199:image/datascience-1.0"
359+
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:eu-west-1:470317259841:image/datascience-1.0"
363360
},
364361
"language_info": {
365362
"codemirror_mode": {

0 commit comments

Comments
 (0)