2016-08-20 2 views
2

feed_dictを使用して、その場でバッチを作成するスマートな方法はありませんか?フードの下に何か助けてくれるものはありますか?私のトレーニングデータはリストにロードされますが、バッチ処理はされません。 feed_dictを使ってランダムにバッチを選択することができます。データを事前にバッチする必要はありません。例えばTensorflowとfeed_dictとバッチングトレーニングセット

私は:

X及びYは、標準的なNNの入力と出力であり、Xの長さは、トレーニング例の数である
for i in range(N_STEPS): 
     sess.run(train_step, feed_dict={x_: X, y_: Y}) 

。バッチ作成のために人々は何を提案していますか?

これは、私は下のトリックを行うかもしれないと思ったが、もっとエレガントなものがなければならないのだろうか?

batch = random.randrange(0, len(X)-N_BATCH) 
sess.run(train_step, feed_dict={x_: X[batch:batch+N_BATCH], y_: Y[batch:batch+N_BATCH]}) 

答えて

1

Googleが作成udacity上tensorflowコースはtf_train_datasettf.placeholderを使用して定義tf_train_labelsでバッチ for step in range(num_steps): # Pick an offset within the training data, which has been randomized. # Note: we could use better randomization across epochs. offset = (step * batch_size) % (train_labels.shape[0] - batch_size) # Generate a minibatch. batch_data = train_dataset[offset:(offset + batch_size), :] batch_labels = train_labels[offset:(offset + batch_size), :] # Prepare a dictionary telling the session where to feed the minibatch. # The key of the dictionary is the placeholder node of the graph to be fed, # and the value is the numpy array to feed to it. feed_dict = {tf_train_dataset : batch_data, tf_train_labels : batch_labels} については、以下を使用しています。

関連する問題