私は現在、仕事で開発中の深い学習アプリケーションのためにTensorflowを使用しています。アプリケーションについて具体的な内容はわかりませんが、コードはカスタマイズされたWord2Vecのようなものですが、各単語ベクトル表現のコストは個別に計算する必要があります。 :Tensorflowグラフが大きくなりすぎる
def cost_function(word_vector, other_word_vectors):
# cost for a single training example needs to be computed
# separately, and it depends on the vector representations
# of some other words, depending on the training instance
return tf.nn.tanh(some_mathematical_computation)
このアプローチの問題は、グラフのサイズがcompute_gradients
操作は多くの時間を要すること、そんなにを爆破する傾向があるということです。それだけでなく、compute_gradients
にかかる時間は、グラフのサイズとともに線形に増加します。 tf.stop_gradients
何らかの理由で助けにならない。助けとなるのは、いくつかのトレーニングインスタンスごとに新しいtf.Graph
と新しいtf.Session()
を初期化し(これをミニバッチと呼ぶ)、並列に複数の計算を実行して(ミニバッチコレクションと呼ぶ)、結果を結合して保存するそれらを次のミニバッチコレクションのために使用します。
def learning(mini_batch):
with tf.Graph().as_default() as g:
with tf.Session() as sess:
self.perform_learning_on_batch(mini_batch, sess)
return resultant_model
def collection_learn(mini_batch_collection):
models = run_learning_in_parallel()
return combine_model(models)
def master():
initial_model = something
for mini_batch_collection in dataset:
new_model = collection_learn(mini_batch_collection)
このようなアプリケーションで並列学習を行うより良い方法はありますか?
ありがとう...勾配降下勾配の簡単な実装を使用して終了しました。テンソルフローで周りを回ることができませんでした。動的なグラフフレームワーク(pytorchのような)が助けになるかどうか? –
勾配降下勾配降下は、分散および並列訓練のためにテンソルフローモデルがデフォルトで使用するものです。 –