2016-06-28 17 views
3

大規模なデータセットでCNNをトレーニングしたいと思います。現在、すべてのデータをtf.constantにロードしてから、tf.Session()の小さなバッチサイズでループします。これは、データセットのごく一部のために正常に動作しますが、私は、入力サイズを大きくするとき、私はエラーを取得する:Tensorflowで大きなデータセットを使用する

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

は、どのように私はそれを避けることができますか?

+0

[2GBを超える配列でtensorflow変数の初期化]の可能複製(https://でのstackoverflow .com/questions/35394103/initializing-tensorflow-variable-with-an-array-larger-than-2gb) – Steven

答えて

5

データを定数にロードしないでください。これは計算グラフの一部になります。

  • はPythonの一部でストリーム形式で
  • ロードデータを、あなたのデータをロードしているオペアンプを作成し、グラフ
3

にバッチを渡すために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}) 
関連する問題