有时,为了调试数据,需要将数据打印打出来,可以用interator来遍历数据
首先定义两个遍历函数,
def print_dataset(self, data_set): iterator = data_set.make_one_shot_iterator() next_element = iterator.get_next() num_batch = 0 with tf.train.MonitoredTrainingSession() as sess: while not sess.should_stop(): value = sess.run(next_element) num_batch += 1 print("