How to use _smoke_test method in lisa

Best Python code snippet using lisa_python

tests.py

Source:tests.py Github

copy

Full Screen

...3import torch4from torch import distributions5from pytorch_generative import models6class ModelSmokeTestCase(unittest.TestCase):7 def _smoke_test(self, model, in_channels=1, test_sampling=True):8 shape = (2, in_channels, 5, 5)9 # Test forward().10 batch = torch.rand(shape)11 model(batch)12 if test_sampling:13 # Test unconditional sample().14 model.sample(out_shape=shape)15 # Test that conditional sample() only modifies pixels < 0.16 batch[:, :, 1:, :] = -117 sample = model.sample(conditioned_on=batch)18 self.assertTrue((sample[:, :, 0, :] == batch[:, :, 0, :]).all())19 # TODO(eugenhotaj): Use parameterized tests instead of creating a new method20 # for each model.21 def test_TinyCNN(self):22 model = models.TinyCNN(in_channels=3, out_channels=3)23 self._smoke_test(model, in_channels=3)24 def test_NADE(self):25 model = models.NADE(input_dim=25, hidden_dim=5)26 self._smoke_test(model)27 def test_MADE(self):28 model = models.MADE(input_dim=25, hidden_dims=[32, 32, 32], n_masks=8)29 self._smoke_test(model)30 def test_PixelCNN(self):31 model = models.PixelCNN(32 in_channels=3,33 out_channels=3,34 n_residual=1,35 residual_channels=1,36 head_channels=1,37 )38 self._smoke_test(model, in_channels=3)39 def test_GatedPixelCNN(self):40 model = models.GatedPixelCNN(41 in_channels=3, out_channels=3, n_gated=1, gated_channels=1, head_channels=142 )43 self._smoke_test(model, in_channels=3)44 def test_PixelSNAIL(self):45 model = models.PixelSNAIL(46 in_channels=3,47 out_channels=3,48 n_channels=2,49 n_pixel_snail_blocks=1,50 n_residual_blocks=1,51 attention_key_channels=1,52 attention_value_channels=1,53 )54 self._smoke_test(model, in_channels=3)55 def test_ImageGPT(self):56 model = models.ImageGPT(57 in_channels=3,58 out_channels=3,59 in_size=5,60 n_transformer_blocks=1,61 n_attention_heads=2,62 n_embedding_channels=4,63 )64 self._smoke_test(model, in_channels=3)65 def test_VAE(self):66 model = models.VAE(67 in_channels=3,68 out_channels=3,69 in_size=5,70 latent_dim=1,71 hidden_channels=2,72 n_residual_blocks=1,73 residual_channels=1,74 )75 self._smoke_test(model, in_channels=3, test_sampling=False)76 # TODO(eugenhotaj): Create a function to test VAEs sampling.77 model.sample(n_images=2)78 def test_VQVAE(self):79 model = models.VQVAE(80 in_channels=3,81 out_channels=3,82 hidden_channels=2,83 n_residual_blocks=1,84 residual_channels=1,85 n_embeddings=2,86 embedding_dim=2,87 )88 self._smoke_test(model, in_channels=3, test_sampling=False)89 def test_VQVAE2(self):90 model = models.VQVAE(91 in_channels=3,92 out_channels=3,93 hidden_channels=2,94 n_residual_blocks=1,95 residual_channels=1,96 n_embeddings=2,97 embedding_dim=2,98 )...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful