我有一段代碼,我想提交給Google雲端ml。我已經測試了他們的例子並得到了結果。向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)))
這是在張量流中訓練和創建DNN模型的代碼。我已經在本地進行了測試並收到了結果。我將這段代碼放在一個名爲trainer的文件夾中,並且init.py文件,並將文件夾上傳到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
我不知道,如果包路徑和模塊的名稱是正確的。請告訴我該怎麼做。感謝 問候,
注意與您的問題直接相關,但我看到您的數據集是本地目錄的硬編碼路徑。在提交給雲之前,您需要確保指向GCS對象的那些對象。 – rhaertel80