tf 版本更新 記錄


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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM