Python 在Tensorflow中使用大型数据集
我想训练一个拥有大数据集的CNN。目前,我将所有数据加载到tf.constant中,然后在tf.Session()中以较小的批处理大小对其进行循环。这对于数据集的一小部分很好,但当我增加输入大小时,会出现错误:Python 在Tensorflow中使用大型数据集,python,machine-learning,computer-vision,tensorflow,Python,Machine Learning,Computer Vision,Tensorflow,我想训练一个拥有大数据集的CNN。目前,我将所有数据加载到tf.constant中,然后在tf.Session()中以较小的批处理大小对其进行循环。这对于数据集的一小部分很好,但当我增加输入大小时,会出现错误: ValueError: Cannot create a tensor proto whose content is larger than 2GB. 如何避免这种情况?不要将数据加载到常量,它将是计算图的一部分 你应该: 创建以流方式加载数据的op 在python部件中加载数据,并使
ValueError: Cannot create a tensor proto whose content is larger than 2GB.
如何避免这种情况?不要将数据加载到常量,它将是计算图的一部分 你应该:
- 创建以流方式加载数据的op
- 在python部件中加载数据,并使用feed_dict将批传递到图形中
X_init = tf.placeholder(tf.float32, shape=(m_input, n_input))
X = tf.Variable(X_init)
sess.run(tf.global_variables_initializer(), feed_dict={X_init: data_for_X})
my_graph = tf.Graph()
sess = tf.Session(graph=my_graph)
with my_graph.as_default():
X_init = tf.placeholder(tf.float32, shape=(m_input, n_input))
X = tf.Variable(X_init)
sess.run(tf.global_variables_initializer(), feed_dict={X_init: data_for_X})
.... # build your graph with X here
.... # Do some other things here
with my_graph.as_default():
output_y = sess.run(your_graph_output, feed_dict={other_placeholder: other_data})