使用存储在Google Cloud上的培训TFRecords

7ha*_*ker 13 tensorflow google-cloud-ml google-cloud-ml-engine

我的目标是在本地运行Tensorflow培训应用程序时使用存储在Google云端存储上的培训数据(格式:tfrecords).(为什么在本地?:我在测试之前将其转换为Cloud ML的培训包)

基于这个线程我不应该做任何事情,因为底层的Tensorflow API应该能够读取gs://(url)

然而事实并非如此,我看到的错误是格式:

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

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

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

我无法跟踪我必须开始调试此错误的位置.

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

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)
Run Code Online (Sandbox Code Playgroud)

rha*_*l80 25

尝试执行以下命令

gcloud auth application-default login