摘要:使用新的tf.contrib.data.Dataset使图形protobuff文件的大小加倍,我无法在Tensorboard中显示图形。Tensorflow数据集API双打图原始文件大小
细节:
我一起tf.contrib.learn.Experiment
框架尝试新TensorFlow tf.contrib.data.Dataset
功能。我的输入数据被定义为input functions,它返回特征和标签的张量。
如果我创建具有tf.train.slice_input_producer
功能我输入功能就像下面的代码块(完整的代码here),然后我得到的graph.pbtxt
文件是620M和.meta
文件大小约为165M。
def train_inputs():
with tf.name_scope('Training_data'):
x = tf.constant(mnist.train.images.reshape([-1, 28, 28, 1]))
y = tf.constant(mnist.train.labels)
sliced_input = tf.train.slice_input_producer(
tensor_list=[x, y], shuffle=True)
return tf.train.shuffle_batch(
sliced_input, batch_size=batch_size,
capacity=10000, min_after_dequeue=batch_size*10)
现在,如果我创造我输入功能与新tf.contrib.data.Dataset.from_tensor_slices
就像下面的代码块(完整的代码here),然后我得到的graph.pbtxt
文件的大小加倍到1.3G和.meta
文件一倍大小330M。
def train_inputs():
with tf.name_scope('Training_data'):
images = mnist.train.images.reshape([-1, 28, 28, 1])
labels = mnist.train.labels
dataset = tf.contrib.data.Dataset.from_tensor_slices(
(images, labels))
dataset = dataset.repeat(None) # Infinite
dataset = dataset.shuffle(buffer_size=10000)
dataset = dataset.batch(batch_size)
iterator = dataset.make_one_shot_iterator()
next_example, next_label = iterator.get_next()
return next_example, next_label
现在因为graph.pbtxt
文件是如此之大TensorBoard需要年龄来解析这个文件,我无法直观地调试我的模型图。 我发现在Dataset documentation,这种增加的大小来自:“阵列的内容将被复制多次”和solution将使用占位符。使用tf.contrib.learn.Experiment
框架时不过
sess.run(iterator.initializer, feed_dict={features_placeholder: features, labels_placeholder: labels})
这似乎,是在我的掌握:然而,在这种情况下,我需要在numpy的阵列送入占位符有活动会话初始化迭代器。
如何使用实验框架初始化迭代器的初始化程序?或者找到解决方案来使用数据集API而不增加我的图表大小?
不错。也解决了我的问题。但似乎是一种解决方法? 我的帖子:https://stackoverflow.com/questions/46207211/tensorflow-dataset-api-causes-graph-size-to-explode –