Google cloud platform 如何在Google云机器学习引擎上训练Keras模型
我可以在谷歌云机器学习引擎上训练tensorflow模型。但是当我使用Keras代码时,我在google cloud上得到错误Google cloud platform 如何在Google云机器学习引擎上训练Keras模型,google-cloud-platform,keras,Google Cloud Platform,Keras,我可以在谷歌云机器学习引擎上训练tensorflow模型。但是当我使用Keras代码时,我在google cloud上得到错误没有名为Keras的模块。我发现要在google cloud上使用Keras,必须使用setup.py脚本安装它,并将它放在运行gcloud命令的同一个文件夹中: ├── setup.py └── trainer ├── __init__.py ├── cloudml-gpu.yaml ├── example5-keras.py 并在setup.
没有名为Keras的模块。我发现要在google cloud上使用Keras,必须使用setup.py脚本安装它,并将它放在运行gcloud命令的同一个文件夹中:
├── setup.py
└── trainer
├── __init__.py
├── cloudml-gpu.yaml
├── example5-keras.py
并在setup.py中放置以下内容:
from setuptools import setup, find_packages
setup(name='example5',
version='0.1',
packages=find_packages(),
description='example to run keras on gcloud ml-engine',
author='Fuyang Liu',
author_email='fuyang.liu@example.com',
license='MIT',
install_requires=[
'keras',
'h5py'
],
zip_safe=False)
然后,您可以在gcloud上启动作业,例如:
export BUCKET_NAME=tf-learn-simple-sentiment
export JOB_NAME="example_5_train_$(date +%Y%m%d_%H%M%S)"
export JOB_DIR=gs://$BUCKET_NAME/$JOB_NAME
export REGION=europe-west1
gcloud ml-engine jobs submit training $JOB_NAME \
--job-dir gs://$BUCKET_NAME/$JOB_NAME \
--runtime-version 1.0 \
--module-name trainer.example5-keras \
--package-path ./trainer \
--region $REGION \
--config=trainer/cloudml-gpu.yaml \
-- \
--train-file gs://tf-learn-simple-sentiment/sentiment_set.pickle
要使用GPU,请在模块中添加一个文件,如cloudml GPU.yaml
,内容如下:
trainingInput:
scaleTier: CUSTOM
# standard_gpu provides 1 GPU. Change to complex_model_m_gpu for 4
GPUs
masterType: standard_gpu
runtimeVersion: "1.0"
如何在python脚本中加载gs://文件?