Skip to content

Commit

Permalink
Update HMM tests
Browse files Browse the repository at this point in the history
  • Loading branch information
borchero committed Apr 5, 2020
1 parent 9273db7 commit fbe121a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

run-tests:
docker:
- image: borchero/pyblaze:latest
- image: borchero/pycave:latest
steps:
- checkout
- run: |
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
torch>=1.4.0,<2.0.0
numpy>=1.18.2,<2.0.0
pyblaze>=1.1.3,<2.0.0
pyblaze>=1.1.4,<2.0.0
12 changes: 6 additions & 6 deletions tests/bayes/hmm_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_forward(self):

# 1) Simple forward application
seq = torch.as_tensor([[2, 2, 0], [1, 2, 1]])
out = hmm.predict(seq)
out = hmm.predict(seq, parallel=False)

self.assertAlmostEqual(out[0, 0].item(), 0.2213, places=4)
self.assertAlmostEqual(out[0, 1].item(), 0.7787, places=4)
Expand All @@ -30,7 +30,7 @@ def test_forward(self):
seqs = torch.nn.utils.rnn.pack_sequence([
torch.as_tensor([1, 2, 1, 1]), torch.as_tensor([2, 2, 0]), torch.as_tensor([0, 1])
])
out = hmm.predict(seqs)
out = hmm.predict(seqs, parallel=False)

self.assertAlmostEqual(out[0, 0].item(), 0.9550, places=4)
self.assertAlmostEqual(out[0, 1].item(), 0.0450, places=4)
Expand All @@ -45,7 +45,7 @@ def test_forward(self):
seqs = torch.nn.utils.rnn.pack_sequence([
torch.as_tensor([0, 1]), torch.as_tensor([1, 2, 1, 1]), torch.as_tensor([2, 2, 0])
], enforce_sorted=False)
out = hmm.predict(seqs)
out = hmm.predict(seqs, parallel=False)

self.assertAlmostEqual(out[0, 0].item(), 0.9082, places=4)
self.assertAlmostEqual(out[0, 1].item(), 0.0918, places=4)
Expand All @@ -67,7 +67,7 @@ def test_smoothing(self):

# 1) Simple smoothing
seq = torch.as_tensor([[2, 2, 0], [1, 2, 1]])
out = hmm.predict(seq, smooth=True)
out = hmm.predict(seq, smooth=True, parallel=False)

self.assertTrue(torch.allclose(
out[0], torch.as_tensor([[0.3847, 0.6153], [0.2156, 0.7844], [0.2213, 0.7787]]),
Expand All @@ -82,7 +82,7 @@ def test_smoothing(self):
seqs = torch.nn.utils.rnn.pack_sequence([
torch.as_tensor([1, 2, 1, 1]), torch.as_tensor([2, 2, 0]), torch.as_tensor([0, 1])
])
out = hmm.predict(seqs, smooth=True)
out = hmm.predict(seqs, smooth=True, parallel=False)

self.assertTrue(torch.allclose(
out[0], torch.as_tensor([
Expand All @@ -102,7 +102,7 @@ def test_smoothing(self):
seqs = torch.nn.utils.rnn.pack_sequence([
torch.as_tensor([0, 1]), torch.as_tensor([1, 2, 1, 1]), torch.as_tensor([2, 2, 0])
], enforce_sorted=False)
out = hmm.predict(seqs, smooth=True)
out = hmm.predict(seqs, smooth=True, parallel=False)

self.assertTrue(torch.allclose(
out[0], torch.as_tensor([[0.7342, 0.2658], [0.9082, 0.0918]]),
Expand Down

0 comments on commit fbe121a

Please sign in to comment.