项目作者: Aashish-1008

项目描述 :
package for ml training in GCP
高级语言: Python
项目地址: git://github.com/Aashish-1008/ml-trainer.git
创建时间: 2019-04-03T09:50:30Z
项目社区:https://github.com/Aashish-1008/ml-trainer

开源协议:BSD 2-Clause "Simplified" License

下载


google-cloud-ml-engine

This repo will train the model on google cloud ml engine & host the model in ml engine.

Installation

Ludwig has been developed and tested with Python 3 in mind. If you don’t have Python 3 installed, install it by running:

  1. # on ubuntu
  2. sudo apt install python3
  3. # on mac
  4. brew install python3

Using local python

You can run the code locally

  1. JOB_DIR=jobDir
  2. TRAIN_FILE=./data/train/*
  3. EVAL_FILE=./data/eval/*
  4. TRAIN_STEPS=2000
  5. cd tf-ludwig-google-cloud-ml-engine/
  6. python3.6 -m trainer.task --train-files $TRAIN_FILE \
  7. --eval-files $EVAL_FILE \
  8. --job-dir $JOB_DIR \
  9. --train-steps $TRAIN_STEPS.
  10. '''

gsutil cp remote-train local-train

‘’’

Using local python

You can run the Keras code locally

  1. JOB_DIR=job_dir
  2. TRAIN_FILE=./data/train/*
  3. EVAL_FILE=./data/eval/*
  4. TRAIN_STEPS=2000
  5. python -m trainer.task --train-files $TRAIN_FILE \
  6. --eval-files $EVAL_FILE \
  7. --job-dir $JOB_DIR \
  8. --train-steps $TRAIN_STEPS

Training using gcloud local

You can run Keras training using gcloud locally

  1. JOB_DIR=job_dir
  2. TRAIN_STEPS=200
  3. gcloud ml-engine local train --package-path trainer \
  4. --module-name trainer.task \
  5. -- \
  6. --train-files $TRAIN_FILE \
  7. --eval-files $EVAL_FILE \
  8. --job-dir $JOB_DIR \
  9. --train-steps $TRAIN_STEPS \
  10. --python-version 3.6 \
  11. --runtime-version 1.10

Prediction using gcloud local

You can run prediction on the SavedModel created from Keras HDF5 model

  1. gcloud ml-engine local predict --model-dir=./models/h5/export/1544372069/ --json-instances request.json

Training using Cloud ML Engine

You can train the model on Cloud ML Engine

  1. JOB_NAME=flowerv15
  2. REGION=us-east1
  3. JOB_DIR=gs://skyl-dev-ml/aashishdahiya/flowers_aashishdahiya_testV3_20181205_134432/$JOB_NAME
  4. GCS_TRAIN_FILE=gs://skyl-dev-ml/aashishdahiya/flowers_aashishdahiya_testV3_20181205_134432/preproc/train*
  5. GCS_EVAL_FILE=gs://skyl-dev-ml/aashishdahiya/flowers_aashishdahiya_testV3_20181205_134432/preproc/eval*
  6. gcloud ml-engine jobs submit training $JOB_NAME \
  7. --stream-logs \
  8. --runtime-version 1.10 \
  9. --python-version 3.5 \
  10. --job-dir $JOB_DIR \
  11. --package-path trainer \
  12. --module-name trainer.task \
  13. --region $REGION \
  14. -- \
  15. --train-files $GCS_TRAIN_FILE \
  16. --eval-files $GCS_EVAL_FILE \
  17. --train-steps $TRAIN_STEPS

Prediction using Cloud ML Engine

You can perform prediction on Cloud ML Engine by following the steps below.
Create a model on Cloud ML Engine
Export the model binaries
Deploy the model to the prediction service
Run the online prediction

  1. MODEL_NAME=skyl_flower
  2. REGION=us-east1
  3. VERSION=v1
  4. MODEL_BINARIES=gs://skyl-dev-ml/aashishdahiya/flowers_aashishdahiya_testV3_20181205_134432/flowerv15/export/1544433235/
  5. gcloud ml-engine models create $MODEL_NAME --regions $REGION
  6. gcloud ml-engine versions create $VERSION --model $MODEL_NAME --origin $MODEL_BINARIES --runtime-version 1.10
  7. gcloud ml-engine predict --model $MODEL_NAME --version v1 --json-instances ./request.json