使用存储在Google Cloud上的Training TFRecords [英] Using Training TFRecords that are stored on Google Cloud

查看:131
本文介绍了使用存储在Google Cloud上的Training TFRecords的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是在本地运行Tensorflow Training App时使用存储在Google Cloud存储中的培训数据(格式:tfrecords). (为什么要在本地?:在将其转换为Cloud ML培训包之前,我正在测试)

My goal is to use training data (format: tfrecords) stored on Google Cloud storage when I run my Tensorflow Training App, locally. (Why locally? : I am testing before I turn it into a training package for Cloud ML)

基于此线程,由于底层Tensorflow API应该能够读取gs://(url)

Based on this thread I shouldn't have to do anything since the underlying Tensorflow API's should be able to read a gs://(url)

但是事实并非如此,我看到的错误的格​​式为:

However thats not the case and the errors I see are of the format:

2017-06-06 15:38:55.589068:我 tensorflow/core/platform/cloud/retrying_utils.cc:77]该操作 失败,将在1.38118秒内自动重试(尝试1 之10),原因:不可用:执行HTTP请求时出错 (HTTP响应代码0,错误代码6,错误消息无法解析 主机元数据")

2017-06-06 15:38:55.589068: I tensorflow/core/platform/cloud/retrying_utils.cc:77] The operation failed and will be automatically retried in 1.38118 seconds (attempt 1 out of 10), caused by: Unavailable: Error executing an HTTP request (HTTP response code 0, error code 6, error message 'Couldn't resolve host 'metadata'')

2017-06-06 15:38:56.976396:我 tensorflow/core/platform/cloud/retrying_utils.cc:77]该操作 失败,将在1.94469秒内自动重试(尝试2 之10),原因:不可用:执行HTTP请求时出错 (HTTP响应代码0,错误代码6,错误消息无法解析 主机元数据")

2017-06-06 15:38:56.976396: I tensorflow/core/platform/cloud/retrying_utils.cc:77] The operation failed and will be automatically retried in 1.94469 seconds (attempt 2 out of 10), caused by: Unavailable: Error executing an HTTP request (HTTP response code 0, error code 6, error message 'Couldn't resolve host 'metadata'')

2017-06-06 15:38:58.925964:我 tensorflow/core/platform/cloud/retrying_utils.cc:77]该操作 失败,将在2.76491秒内自动重试(尝试3 之10),原因:不可用:执行HTTP请求时出错 (HTTP响应代码0,错误代码6,错误消息无法解析 主机元数据")

2017-06-06 15:38:58.925964: I tensorflow/core/platform/cloud/retrying_utils.cc:77] The operation failed and will be automatically retried in 2.76491 seconds (attempt 3 out of 10), caused by: Unavailable: Error executing an HTTP request (HTTP response code 0, error code 6, error message 'Couldn't resolve host 'metadata'')

我无法按照我必须开始调试此错误的地方进行操作.

I'm not able to follow where I have to begin debugging this error.

这是一个重现该问题的代码段,还显示了我正在使用的tensorflow API.

Here is a snippet that reproduced the problem and also shows the tensorflow API's that I am using.

def _preprocess_features(features):
        """Function that returns preprocessed images"""

def _parse_single_example_from_tfrecord(value):
    features = (
        tf.parse_single_example(value,
                                features={'image_raw': tf.FixedLenFeature([], tf.string),
                                          'label': tf.FixedLenFeature([model_config.LABEL_SIZE], tf.int64)
                                          })
        )
    return features

def _read_and_decode_tfrecords(filename_queue):
    reader = tf.TFRecordReader()
    # Point it at the filename_queue
    _, value = reader.read(filename_queue)
    features = _parse_single_example_from_tfrecord(value)
    # decode the binary string image data
    image, label = _preprocess_features(features)
    return image, label

def test_tfread(filelist):
  train_filename_queue = (
    tf.train.string_input_producer(filelist,
                                   num_epochs=None,
                                   shuffle=True))
  image, label = (
    _read_and_decode_tfrecords(train_filename_queue))
  return image

images= test_tfread(["gs://test-bucket/t.tfrecords"])
sess = tf.Session(config=tf.ConfigProto(
                allow_soft_placement=True,
                log_device_placement=True))
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
try:
  for step in range(model_config.MAX_STEPS):
      _ = sess.run([images])
finally:
  # When done, ask the threads to stop.
  coord.request_stop()
# Finally, wait for them to join (i.e. cleanly shut down)
coord.join(threads)

推荐答案

尝试执行以下命令

gcloud auth application-default login

这篇关于使用存储在Google Cloud上的Training TFRecords的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆