Пример #1
0
    def test_inference_no_head(self):
        model = YosoModel.from_pretrained("uw-madison/yoso-4096")
        input_ids = torch.tensor([[0, 1, 2, 3, 4, 5]])

        with torch.no_grad():
            output = model(input_ids)[0]

        expected_shape = torch.Size((1, 6, 768))
        self.assertEqual(output.shape, expected_shape)

        expected_slice = torch.tensor([[[-0.0611, 0.1242, 0.0840],
                                        [0.0280, -0.0048, 0.1125],
                                        [0.0106, 0.0226, 0.0751]]])

        self.assertTrue(
            torch.allclose(output[:, :3, :3], expected_slice, atol=1e-4))
Пример #2
0
 def test_model_from_pretrained(self):
     for model_name in YOSO_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         model = YosoModel.from_pretrained(model_name)
         self.assertIsNotNone(model)