【发布时间】:2017-12-02 23:27:35
【问题描述】:
我创建了tf records 文件,这些文件存储在谷歌存储桶上。我有一个在 ml-engine 上运行的代码,可以使用这些 tf records 中的数据训练模型
每个 tf 记录文件包含一批 20 个示例,大小约为 8Mb(Mega 字节)。存储桶上有几千个文件。
我的问题是开始训练需要很长时间。从加载包的那一刻到实际开始训练的那一刻,我必须等待大约 40 分钟。我猜这是下载数据和填满队列所需的时间?
代码如下(为简洁起见略有简化):
# Create a queue which will produce tf record names
filename_queue = tf.train.string_input_producer(files, num_epochs=num_epochs, capacity=100)
# Read the record
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
# Map for decoding the serialized example
features = tf.parse_single_example(
serialized_example,
features={
'data': tf.FixedLenFeature([], tf.float32),
'label': tf.FixedLenFeature([], tf.int64)
})
train_tensors = tf.train.shuffle_batch(
[features['data'], features['label']],
batch_size=30,
capacity=600,
min_after_dequeue=400,
allow_smaller_final_batch=True
enqueue_many=True)
我检查了我的存储桶和我的工作共享相同的region 参数。
我不明白为什么要花这么长时间:应该只是下载几百 Mbs 的问题(几十个 tf 记录文件应该足以在队列中包含超过 min_after_dequeue 元素)。
知道我遗漏了什么,或者问题可能出在哪里吗?
谢谢
【问题讨论】:
-
你使用的是什么--runtime-version?我推荐使用 TF 1.4(刚刚发布)。您是否尝试在从 GCS 加载数据时在本地运行?如果您的情况可行,请报告本地需要多长时间。
-
昨天刚发布?因为我在 2 天前尝试过,但无法使用 --runtime-version 1.4 运行。无论如何,我观察到与 TF 1.4 相同的行为。但是我认为我已经找到了问题(见答案),所以我将可耻地关闭问题
-
TF 1.4 于昨天正式发布。我们认为 TF 本身可能存在错误,因此需要在正式发布之前解决该问题。
标签: google-cloud-ml