[Relay][Frontend] Fix tensorflow frontend lstm forget bias adding order (#3410)
authorttyang1018 <ttyang1018@outlook.com>
Thu, 27 Jun 2019 17:01:17 +0000 (01:01 +0800)
committerTianqi Chen <tqchen@users.noreply.github.com>
Thu, 27 Jun 2019 17:01:17 +0000 (10:01 -0700)
python/tvm/relay/frontend/tensorflow.py
tests/python/frontend/tensorflow/test_forward.py

index 1b55731..d754e85 100644 (file)
@@ -1437,9 +1437,8 @@ def _LSTMBlockCell():
         gate_list = _op.split(gates_bias, indices_or_sections=4, axis=1)
         in_gate = _op.sigmoid(gate_list[0])
         in_transform = _op.tanh(gate_list[1])
-        forget_gate = _op.sigmoid(gate_list[2])
-        forget_gate = _op.add(forget_gate,
-                              tvm.relay.const(forget_bias, attr['T'].name))
+        forget_gate = _op.add(gate_list[2], tvm.relay.const(forget_bias, attr['T'].name))
+        forget_gate = _op.sigmoid(forget_gate)
         out_gate = _op.sigmoid(gate_list[3])
         next_c = _op.add(_op.multiply(forget_gate, in_state_c),
                          _op.multiply(in_gate, in_transform))
index 5dbe471..da8fd1d 100644 (file)
@@ -1183,7 +1183,7 @@ def _test_lstm_cell(batch_size, num_hidden, num_layers, forget_bias, dtype):
 
 def test_forward_lstm():
     '''test LSTM block cell'''
-    _test_lstm_cell(1, 2, 1, 0.0, 'float32')
+    _test_lstm_cell(1, 2, 1, 0.5, 'float32')