tf 經常更新版本,網上教程又是各版本都有,且不標明版本,致使各種用法難以分清哪個新,哪個舊,這里做個記錄,以前的博客我就不更新了,請大家見諒。
tf.nn.rnn_cell 改為 tf.contrib.rnn
# 原代碼 lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(HIDDEN_SIZE) if is_training: lstm_cell = tf.nn.rnn_cell.DropoutWrapper(lstm_cell, output_keep_prob=KEEP_PROB) cell = tf.nn.rnn_cell.MultiRNNCell([lstm_cell] * NUM_LAYERS) # 修改為 lstm_cell = tf.contrib.rnn.BasicLSTMCell(HIDDEN_SIZE) if is_training: lstm_cell = tf.contrib.rnn.DropoutWrapper(lstm_cell, output_keep_prob=KEEP_PROB) cell = tf.contrib.rnn.MultiRNNCell([lstm_cell] * NUM_LAYERS)
tf.nn.seq2seq.sequence_loss_by_example 改為 tf.contrib.legacy_seq2seq.sequence_loss_by_example
# 原代碼 loss = tf.nn.seq2seq.sequence_loss_by_example( [logits], [tf.reshape(self.targets, [-1])], [tf.ones([batch_size * num_steps], dtype=tf.float32)]) # 修改為 loss = tf.contrib.legacy_seq2seq.sequence_loss_by_example( [logits], [tf.reshape(self.targets, [-1])], [tf.ones([batch_size * num_steps], dtype=tf.float32)])
tf.concat
# 原代碼 concated = tf.concat(1, [indices, labels]) # 修改為 concated = tf.concat([indices, labels], 1)