Skip to content

Instantly share code, notes, and snippets.

@crawles
Last active May 23, 2018 18:46
Show Gist options
  • Save crawles/029c0500077a61555deb76020c98db6e to your computer and use it in GitHub Desktop.
Save crawles/029c0500077a61555deb76020c98db6e to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train on the cloud using `ml-engine`\n",
"Note the arguments to `ml-engine`. Those before the empty `--` are specific to ML Engine, while those after, named `USER_ARGS`, are for your package."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"TRAIN_DATA_PATHS=path/to/training/data\n",
"OUTPUT_DIR=path/to/output/location\n",
"JOBNAME=my_ml_job_$(date -u +%y%m%d_%H%M%S)\n",
"REGION='us-central1'\n",
"BUCKET='my-bucket-name'\n",
"\n",
"gcloud ml-engine jobs submit training $JOBNAME \\\n",
" --package-path=$PWD/training_example/trainer \\\n",
" --module-name=trainer.task \\\n",
" --region=$REGION \\\n",
" --staging-bucket=gs://$BUCKET \\\n",
" --scale-tier=BASIC \\\n",
" --runtime-version=1.8 \\\n",
" -- \\ # Required.\n",
" --train_data_paths $TRAIN_DATA_PATHS \\\n",
" --output_dir $OUTPUT_DIR\\\n",
" --batch_size 100\\\n",
" --hidden_units 50,25,10"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.14"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment