Skip to content

Commit cfeadff

Browse files
committed
[layer] BiRNNLayer for TF 1.0, 0.12, 0.11, 0.10
1 parent e4114f9 commit cfeadff

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tensorlayer/layers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3265,7 +3265,12 @@ def __init__(
32653265
list_rnn_inputs = tf.unstack(self.inputs, axis=1)
32663266
except: ## TF0.12
32673267
list_rnn_inputs = tf.unpack(self.inputs, axis=1)
3268-
outputs, fw_state, bw_state = tf.contrib.rnn.static_bidirectional_rnn(
3268+
3269+
if tf.__version__ <= "0.12": # TF 0.10, 0.11, 0.12
3270+
bidirectional_rnn_fn = tf.nn.bidirectional_rnn
3271+
else: # TF 1.0
3272+
bidirectional_rnn_fn = tf.contrib.rnn.static_bidirectional_rnn
3273+
outputs, fw_state, bw_state = bidirectional_rnn_fn( # outputs, fw_state, bw_state = tf.contrib.rnn.static_bidirectional_rnn(
32693274
cell_fw=self.fw_cell,
32703275
cell_bw=self.bw_cell,
32713276
inputs=list_rnn_inputs,

0 commit comments

Comments
 (0)