我有一个代码如下,我想提交给 Google cloud ml。我已经测试了他们的例子并得到了结果。
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
import numpy as np
# Data sets
I_TRAINING = "/home/android/Desktop/training.csv"
I_TEST = "/home/android/Desktop/test.csv"
# Load datasets.
training_set = tf.contrib.learn.datasets.base.load_csv(filename=I_TRAINING, target_dtype=np.int)
test_set = tf.contrib.learn.datasets.base.load_csv(filename=I_TEST, target_dtype=np.int)
# Specify that all features have real-value data
feature_columns = [tf.contrib.layers.real_valued_column("", dimension=2)]
# Build 3 layer DNN with 10, 20, 10 units respectively.
classifier = tf.contrib.learn.DNNClassifier(feature_columns=feature_columns,
hidden_units=[10, 20, 10],
n_classes=2,
model_dir="/tmp/my_model")
# Fit model.
classifier.fit(x=training_set.data, y=training_set.target, steps=2000)
# Evaluate accuracy.
accuracy_score = classifier.evaluate(x=test_set.data, y=test_set.target)["accuracy"]
print('Accuracy: {0:f}'.format(accuracy_score))
# Classify two new flower samples.
#new_samples = np.array(
# [[6.4, 3.2, 4.5, 1.5], [5.8, 3.1, 5.0, 1.7]], dtype=float)
#y = classifier.predict(new_samples)
#print('Predictions: {}'.format(str(y)))
这是在 tensorflow 中训练和创建 DNN 模型的代码。我已经在本地进行了测试并收到了结果。我将此代码与init .py 文件一起放在名为 trainer 的文件夹中,并将该文件夹上传到 gs://bucket-ml/second_job/trainer。Second_job 是 JOB_NAME。
然后,当我想将此作为作业提交时,我这样做并收到以下错误:
gcloud beta ml jobs submit training ${JOB_NAME} \
--package-path=trainer \
--module-name=trainer.trainer \
--staging-bucket="${TRAIN_BUCKET}" \
--region=us-central1 \
--train_dir="${TRAIN_PATH}/train"
ERROR: (gcloud.beta.ml.jobs.submit.training)
Packaging of user python code failed with message:
running sdist
running egg_info
creating trainer.egg-info
writing trainer.egg-info/PKG-INFO
writing top-level names to trainer.egg-info/top_level.txt
writing dependency_links to trainer.egg-info/dependency_links.txt
writing manifest file 'trainer.egg-info/SOURCES.txt'
error: package directory 'trainer' does not exist
Try manually writing a setup.py file at your package root
and rerunning the command
我不确定包路径和模块名称是否正确。请告诉我该怎么做。感谢和问候,