def test_dump_load(self): self.tt_encoder.dump(self.dump_path) tt_encoder2 = BaseEncoder.load(self.dump_path) vec = tt_encoder2.encode(self.test_str) self.assertEqual(vec.shape[0], len(self.test_str)) self.assertEqual(vec.shape[1], 768)
def test_dump_load(self): self.encoder = BaseEncoder.load_yaml(self.yaml_path) self.encoder.dump(self.dump_path) encoder2 = BaseEncoder.load(self.dump_path) vec = encoder2.encode(self.test_frames) self.assertEqual(vec.shape[0], 3) self.assertEqual(vec.shape[1], 19310)
def test_dummytf(self): d1 = DummyTFEncoder() self.assertEqual(d1.encode(1), 2) self.assertTrue(d1.is_trained) d1.dump() d11 = BaseEncoder.load(d1.dump_full_path) self.assertTrue(d11.is_trained) d2 = DummyTFEncoder() self.assertEqual(d2.encode(2), 3) self.assertTrue(d2.is_trained) d3 = PipelineEncoder() d3.component = lambda: [d1, d2] self.assertEqual(d3.encode(1), 3) self.assertFalse(d3.is_trained) self.assertTrue(d3.component[0].is_trained) self.assertTrue(d3.component[1].is_trained) d3.dump() d31 = BaseEncoder.load(d3.dump_full_path) self.assertFalse(d31.is_trained) self.assertTrue(d31.component[0].is_trained) self.assertTrue(d31.component[1].is_trained) d3.work_dir = self.dirname d3.name = 'dummy-pipeline' d3.is_trained = True d3.dump_yaml() d3.dump() d4 = PipelineEncoder.load(d3.dump_full_path) self.assertTrue(d4.is_trained) self.assertTrue(d4.component[0].is_trained) self.assertTrue(d4.component[1].is_trained) d4 = PipelineEncoder.load_yaml(d3.yaml_full_path) self.assertTrue(d4.is_trained) self.assertTrue(d4.component[0].is_trained) self.assertTrue(d4.component[1].is_trained) self.assertEqual(d4.encode(4), 6)
def test_dump_load(self): self.encoder = BaseEncoder.load_yaml(self.yaml_path) self.encoder.dump(self.dump_path) encoder2 = BaseEncoder.load(self.dump_path) for test_img in self.test_img: vec = encoder2.encode(test_img) self.assertEqual(vec.shape[0], 2) self.assertEqual(vec.shape[1], 2048)
def test_encoding(self): self.encoder = BaseEncoder.load_yaml(self.yaml_path) # train before encode to create pca_components self.encoder.train(self.test_numeric) vec = self.encoder.encode(self.test_numeric) self.assertEqual(vec.shape, (1000, 300)) # dump after train with valied pca_components self.encoder.dump(self.dump_path) encoder2 = BaseEncoder.load(self.dump_path) vec = encoder2.encode(self.test_numeric) self.assertEqual(vec.shape, (1000, 300))
def test_dump_load(self): self.encoder = BaseEncoder.load_yaml(self.vgg_yaml) self.encoder.dump(self.dump_path) vgg_encoder2 = BaseEncoder.load(self.dump_path) for test_img in self.test_img: vec = vgg_encoder2.encode(test_img) self.assertEqual(vec.shape[0], len(test_img)) self.assertEqual(vec.shape[1], 4096)