예제 #1
0
 def create_and_check_model(self, config, pixel_values, labels, pixel_labels):
     model = BeitModel(config=config)
     model.to(torch_device)
     model.eval()
     result = model(pixel_values)
     self.parent.assertEqual(
         result.last_hidden_state.shape, (self.batch_size, self.expected_seq_length, self.hidden_size)
     )
예제 #2
0
 def create_and_check_model(self, config, pixel_values, labels):
     model = BeitModel(config=config)
     model.to(torch_device)
     model.eval()
     result = model(pixel_values)
     # expected sequence length = num_patches + 1 (we add 1 for the [CLS] token)
     image_size = to_2tuple(self.image_size)
     patch_size = to_2tuple(self.patch_size)
     num_patches = (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])
     self.parent.assertEqual(result.last_hidden_state.shape, (self.batch_size, num_patches + 1, self.hidden_size))
예제 #3
0
 def test_model_from_pretrained(self):
     for model_name in BEIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         model = BeitModel.from_pretrained(model_name)
         self.assertIsNotNone(model)