Skip to content

Commit

Permalink
dynet-1187. Add python tests for dynet IO. (#1189)
Browse files Browse the repository at this point in the history
  • Loading branch information
xunzhang authored Jan 16, 2018
1 parent 80ca8ec commit 1790a40
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions tests/python/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,11 @@ def test_concatenate_to_batch(self):
self.assertTrue(np.allclose(w.npvalue(), self.pval.T))


class TestIO_1(unittest.TestCase):

class TestIOEntireModel(unittest.TestCase):
def setUp(self):
self.file = "bilstm.model"
# create models
self.m = dy.ParameterCollection()
self.m2 = dy.ParameterCollection()
# Create birnn
self.b = dy.BiRNNBuilder(2, 10, 10, self.m, dy.LSTMBuilder)

def test_save_load(self):
Expand All @@ -297,8 +294,24 @@ def test_save_load(self):
self.m2.populate(self.file)


class TestIO_2(unittest.TestCase):
class TestIOPartial(unittest.TestCase):
def setUp(self):
self.file = "tmp.model"
self.m = dy.ParameterCollection()
self.m2 = dy.ParameterCollection()
self.L = self.m.add_lookup_parameters((10, 2), name="la")
self.a = self.m.add_parameters(10, name="a")

def test_save_load(self):
self.L.save(self.file, "/X")
self.a.save(self.file, append=True)
a = self.m2.add_parameters(10)
L = self.m2.add_lookup_parameters((10, 2))
L.populate(self.file, "/X")
a.populate(self.file, "/a")


class TestIOHighLevelAPI(unittest.TestCase):
def setUp(self):
self.file = "bilstm.model"
# create models
Expand Down

0 comments on commit 1790a40

Please sign in to comment.