Skip to content

Instantly share code, notes, and snippets.

@nsakki55
Created June 11, 2022 06:26
Show Gist options
  • Save nsakki55/61eac4ca470901c1569042878978677b to your computer and use it in GitHub Desktop.
Save nsakki55/61eac4ca470901c1569042878978677b to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "df08ead8",
"metadata": {},
"outputs": [],
"source": [
"from sagemaker.estimator import Estimator\n",
"\n",
"job_name = \"scratch-container-ctr-prediction-\" + strftime(\"%Y%m%d-%H-%M-%S\", gmtime())\n",
"\n",
"hyperparameters = {\"rank\": 7, \"n_iter\": 12}\n",
"\n",
"enable_local_mode_training=False\n",
"if enable_local_mode_training:\n",
" train_instance_type = \"local\"\n",
" inputs = {\"train\": f\"file://{train_file}\", \"test\": f\"file://{test_file}\"}\n",
"else:\n",
" train_instance_type = \"ml.m5.large\"\n",
" inputs = {\"train\": s3_train_data, \"test\": s3_test_data}\n",
" \n",
"estimator = Estimator(image_uri=f'{account}.dkr.ecr.ap-northeast-1.amazonaws.com/ctr-prediction-scratch-container:latest',\n",
" role=role,\n",
" instance_count=1,\n",
" instance_type=train_instance_type,\n",
" output_path=output_location,\n",
" hyperparameters=hyperparameters,\n",
" base_job_name=job_name)\n",
"\n",
"estimator.fit(inputs)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment