【发布时间】:2018-03-16 09:53:57
【问题描述】:
我的谷歌云存储桶在 gs://MYBucket/demo2/TFRecords/ 下有两个文件夹 train 和 test,其中包含图像的 TFRecords嵌入。我将存储桶的 url 作为参数传递给程序。
在终端中输入以下内容以提交作业:
$training='gs://MYBucket/demo2/'
$gcloud ml-engine jobs submit training $JOB_NAME \
--job-dir $JOB_DIR \
--module-name $TRAINER_MODULE \
--package-path $TRAINER_PATH \
--region $REGION \
-- \
--train-files $training
这里 training 包含我的存储桶的地址
我的代码:
from tensorflow.python.lib.io import file_io
from StringIO import StringIO
BUCKET=None
DATA_DIR = "TFRecords/train/"
~Some code~
def Load_input():
global BUCKET
filenames = [os.path.join(BUCKET+DATA_DIR, "train-0000%d-of-00002.tfrecord" % i) for i in xrange(0, 1)]
for f in filenames:
if not tf.gfile.Exists(f):
raise ValueError("Failed to find file: " + f)
filename_queue = tf.train.string_input_producer(filenames)
~Some code~
def main(unused_args):
parser.add_argument('--train-files',help='BUCKET path to training data',nargs='+',required=True)
args = parser.parse_args()
global BUCKET
BUCKET = StringIO(file_io.read_file_to_string(args.__dict__['train_files'][0]))
~Some other code that internally calls **Load_input()**~
行:
filenames = [os.path.join(BUCKET+DATA_DIR, "train-0000%d-of-00002.tfrecord" % i) for i in xrange(0, 1)]
抛出错误:
TypeError: +: 'instance' 和 'str' 的操作数类型不受支持
我尝试过的:
BUCKET = file_io.read_file_to_string(args.train_files[0])
但它会引发错误:
raise ValueError("Failed to find file: " + f)
ERROR 2018-03-16 15:57:55 +0530 master-replica-0
ValueError: Failed to find file: TFRecords/train/train-00000-of-00002.tfrecord
我的问题: 我应该如何加入 BUCKET 和 DATA_DIR 才能正确提供训练文件的路径?
【问题讨论】:
标签: python google-cloud-platform filepath google-cloud-ml