Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Tensorflow中使用大型数据集_Python_Machine Learning_Computer Vision_Tensorflow - Fatal编程技术网

Python 在Tensorflow中使用大型数据集

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部件中加载数据,并使

我想训练一个拥有大数据集的CNN。目前,我将所有数据加载到tf.constant中,然后在tf.Session()中以较小的批处理大小对其进行循环。这对于数据集的一小部分很好,但当我增加输入大小时,会出现错误:

ValueError: Cannot create a tensor proto whose content is larger than 2GB.

如何避免这种情况?

不要将数据加载到常量,它将是计算图的一部分

你应该:

  • 创建以流方式加载数据的op
  • 在python部件中加载数据,并使用feed_dict将批传递到图形中

对于TensorFlow 1.x和Python 3,有一个简单的解决方案:

实际上,您将主要为连续计算指定图形和会话,以下代码将帮助您:

可能重复的
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})