Skip to content

Commit 5091eba

Browse files
Update test_sequence_models.py
1 parent 142b703 commit 5091eba

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

tests/test_sequence_models.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ def test_language_model_implementation(seq_length, num_layers, batch_size, embed
223223

224224
@pytest.mark.parametrize("device", _DEVICES, ids=["cpu", "cuda"])
225225
def test_language_model_training(device):
226+
np.random.seed(0)
226227
corpus = ndl.data.Corpus("data/ptb", max_lines=20)
227228
seq_len = 10
228229
num_examples = 100
@@ -236,11 +237,12 @@ def test_language_model_training(device):
236237
train_acc, train_loss = train_ptb(model, train_data, seq_len=seq_len, n_epochs=n_epochs, device=device)
237238
test_acc, test_loss = evaluate_ptb(model, train_data, seq_len=seq_len, device=device)
238239
if str(device) == "cpu()":
239-
np.testing.assert_allclose(5.65995, train_loss, atol=1e-5, rtol=1e-5)
240-
np.testing.assert_allclose(5.328376, test_loss, atol=1e-5, rtol=1e-5)
240+
np.testing.assert_allclose(5.711512, train_loss, atol=1e-5, rtol=1e-5)
241+
np.testing.assert_allclose(5.388685, test_loss, atol=1e-5, rtol=1e-5)
241242
elif str(device) == "cuda()":
242-
np.testing.assert_allclose(5.65995, train_loss, atol=1e-5, rtol=1e-5)
243-
np.testing.assert_allclose(5.328376, test_loss, atol=1e-5, rtol=1e-5)
243+
np.testing.assert_allclose(5.711512, train_loss, atol=1e-5, rtol=1e-5)
244+
np.testing.assert_allclose(5.388685, test_loss, atol=1e-5, rtol=1e-5)
245+
244246

245247

246248

0 commit comments

Comments
 (0)