MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / test_lstm_cell

Function test_lstm_cell

imperative/python/test/unit/module/test_rnn.py:38–48  ·  view source on GitHub ↗
(batch_size, input_size, hidden_size, init_hidden)

Source from the content-addressed store, hash-verified

36 [(3, 10, 20, True), (3, 10, 20, False), (1, 10, 20, False)],
37)
38def test_lstm_cell(batch_size, input_size, hidden_size, init_hidden):
39 rnn_cell = LSTMCell(input_size, hidden_size)
40 x = mge.random.normal(size=(batch_size, input_size))
41 if init_hidden:
42 h = F.zeros(shape=(batch_size, hidden_size))
43 hx = (h, h)
44 else:
45 hx = None
46 h_new, c_new = rnn_cell(x, hx)
47 assert_tuple_equal(h_new.shape, (batch_size, hidden_size))
48 assert_tuple_equal(c_new.shape, (batch_size, hidden_size))
49
50
51@pytest.mark.skipif(get_device_count("gpu") > 0, reason="no algorithm on cuda")

Callers

nothing calls this directly

Calls 4

LSTMCellClass · 0.90
assert_tuple_equalFunction · 0.85
normalMethod · 0.80
zerosMethod · 0.45

Tested by

no test coverage detected