tensorflow - 使用存储在Google Cloud中的Training TFRecords

标签 tensorflow google-cloud-ml google-cloud-ml-engine

我的目标是在本地运行Tensorflow Training App时使用存储在Google Cloud存储中的培训数据(格式:tfrecords)。 (为什么要在本地?:在将其转换为Cloud ML培训包之前,我正在测试)
基于this thread我不需要做任何事情,因为基础的Tensorflow API应该能够读取gs://(url)
但是事实并非如此,我看到的错误的格​​式是:

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

最佳答案

尝试执行以下命令

gcloud auth application-default login

关于tensorflow - 使用存储在Google Cloud中的Training TFRecords,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44401088/

相关文章:

c++ - 构建 Tensorflow 时未声明特征仿函数

keras - 为什么 Keras 为单个 .fit 运行编写多个张量板日志?

machine-learning - Tensorflow、谷歌云 ML : how to use previous checkpoint to train new images?

python-3.x - 如何将 .ckpt 转换为 .pb?

tensorflow - 如何将 device_filters 与 tf.contrib.learn.Experiment 结合使用?

tensorflow - 加载预训练的 word2vec 以初始化 Estimator model_fn 中的 embedding_lookup

tensorflow - Mnist 像素边框

python - tensorflow 中的求和池

python - Keras LSTM 多输入多输出