2016-12-16 1 views
0

Ich versuche, einzelne dynamic_rnn zu verwenden, um sehr lange Sequenz für Klassifizierungsaufgabe zu verarbeiten. Hier sind einige Parameter: rnn_size = 500, seq_max_length = 2500, Stapelgröße = 50, embedding_size = 64, softmax_size = 1600.Sehr niedrige GPU-Verwendung

der Code ist wie folgt:

x_vec = tf.nn.embedding_lookup(embedding_matrix_variable, self.x) 
lstm_fw_cell = rnn_cell.LSTMCell(num_units = hidden_unit, input_size = word_dim) 
lstm_fw_cell = rnn_cell.DropoutWrapper(lstm_fw_cell, output_keep_prob=self.dropout_keep_prob, input_keep_prob=self.dropout_keep_prob) 
outputs, _ = rnn.dynamic_rnn(lstm_fw_cell, x, dtype=tf.float32, sequence_length=real_length, swap_memory=False) 

outputs = tf.transpose(outputs, [1, 0, 2]) 
outputs = tf.unpack(outputs) 

output = outputs[0] 
one = tf.ones([1, hidden_unit], tf.float32) 
with tf.variable_scope("output"): 
    tf.get_variable_scope().reuse_variables() 
     for i in range(1, len(outputs_6)): 
      ind = self.real_length < (i+1) 
      ind = tf.to_float(ind) 
      ind = tf.expand_dims(ind, -1) 
      mat = tf.matmul(ind, one) 
      output=tf.add(tf.mul(output, mat), tf.mul(outputs[i], 1.0-mat)) 


y_prediction = tf.matmul(output, w_h2y) + b_h2y 
y_prediction = tf.nn.softmax(y_prediction) 

weight_decay = L2 * (tf.nn.l2_loss(w_h2y) + tf.nn.l2_loss(b_h2y)) 
self.cost = tf.reduce_mean(-tf.reduce_sum(self.y*tf.log(y_prediction + 1e-10))) + weight_decay 
self.optimizer = tf.train.AdamOptimizer(alpha).minimize(self.cost) 

Die Verwendung von GPU auf TITAN nur 5%. Die CPU-Auslastung beträgt ca. 150%. Ich bin mir nicht sicher, was das Problem ist.

+1

Sie haben wahrscheinlich einen Engpass irgendwo, eine Möglichkeit, Engpässe zu finden, ist Timeline Profiling - https://github.com/tensorflow/tensorflow/issues/1824#issuecomment-225754659 –

Antwort

0

Wie Yaroslav bemerkt - das ist eine schwierige Frage zu beantworten, weil es erfordert Profiling Ihres Codes (oder jemand glücklich genug, um das Problem zu erkennen). This comment on the github issues ist ein guter Ausgangspunkt für das Profiling, ebenso wie die neue TensorFlow Performance Seite.

Verwandte Themen