From 7db5779fd7ae9bb6aa1286264f46438fae0290ec Mon Sep 17 00:00:00 2001 From: ttyang1018 Date: Fri, 28 Jun 2019 01:01:17 +0800 Subject: [PATCH] [Relay][Frontend] Fix tensorflow frontend lstm forget bias adding order (#3410) --- python/tvm/relay/frontend/tensorflow.py | 5 ++--- tests/python/frontend/tensorflow/test_forward.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/python/tvm/relay/frontend/tensorflow.py b/python/tvm/relay/frontend/tensorflow.py index 1b55731..d754e85 100644 --- a/python/tvm/relay/frontend/tensorflow.py +++ b/python/tvm/relay/frontend/tensorflow.py @@ -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)) diff --git a/tests/python/frontend/tensorflow/test_forward.py b/tests/python/frontend/tensorflow/test_forward.py index 5dbe471..da8fd1d 100644 --- a/tests/python/frontend/tensorflow/test_forward.py +++ b/tests/python/frontend/tensorflow/test_forward.py @@ -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') -- 2.7.4