def test_denoising_build(self):
     with self.subTest(model_type='denoising'):
         ae = building.build_ae('denoising', (1, 32, 32), anomaly=False)
         self.assertNotEqual(0., ae.noise_ratio)
     with self.subTest(model_type='not denoising'):
         ae = building.build_ae('vanilla', (1, 32, 32), anomaly=False)
         self.assertEqual(0., ae.noise_ratio)
 def test_anomaly_build(self):
     with self.subTest(anomaly=False):
         ae = building.build_ae('vanilla', (1, 32, 32), anomaly=False)
         self.assertEqual(20, ae.encoder.latent_dim)
         self.assertEqual(20, ae.bottleneck.latent_dim)
         self.assertEqual(20, ae.decoder.latent_dim)
     with self.subTest(anomaly=True):
         ae = building.build_ae('vanilla', (1, 32, 32), anomaly=True)
         self.assertEqual(2, ae.encoder.latent_dim)
         self.assertEqual(2, ae.bottleneck.latent_dim)
         self.assertEqual(2, ae.decoder.latent_dim)
示例#3
0
def run(model_type, dataset, batch_size, gpu, anomaly=False):
    assert model_type in AUTOENCODERS
    task = 'anomaly' if anomaly else None
    pl.seed_everything(42)
    datamodule = build_datamodule(dataset, model_type, batch_size, anomaly)
    ae = build_ae(model_type, datamodule.dims, anomaly)
    logger = build_logger(model_type, dataset, task)
    checkpoint_path = _train(model_type, ae, datamodule, logger, gpu)

    return checkpoint_path
示例#4
0
 def setUp(self):
     self.data = MNISTDataModule(data_dir='../data')
     self.data.prepare_data()
     self.data.setup()
     self.net = build_ae('vae', self.data.dims)
     self.latent_viz = Latent(self.net)
示例#5
0
 def setUp(self):
     self.data = MNISTDataModule(data_dir='../data', exclude=9)
     self.data.prepare_data()
     self.data.setup()
     self.net = build_ae('vanilla', self.data.dims)
     self.anomaly_detector = AnomalyDetection(self.net)