Exemplo n.º 1
0
    def test_model_not_training(self):
        data_tensor = torch.tensor(
            [
                [
                    [8, 4, 0, 0, 1, 2],
                    [9, 7, 2, 7, 3, 8],
                    [8, 4, 0, 0, 1, 2]
                ],

                [
                    [8, 4, 0, 0, 1, 2],
                    [9, 7, 2, 7, 3, 8],
                    [8, 4, 0, 0, 1, 2]
                ]
            ],
            dtype=torch.float32
        )

        dropout_p = 0.9
        dim = 0
        is_model_training = False

        result = pwF.sub_tensor_dropout(data_tensor, dropout_p, dim, is_model_training)

        self.assertListEqual(result.tolist(), data_tensor.tolist())
Exemplo n.º 2
0
    def test_large_p_model_training(self):
        data_tensor = torch.tensor(
            [
                [
                    [8, 4, 0, 0, 1, 2],
                    [9, 7, 2, 7, 3, 8],
                    [8, 4, 0, 0, 1, 2]
                ],

                [
                    [8, 4, 0, 0, 1, 2],
                    [9, 7, 2, 7, 3, 8],
                    [8, 4, 0, 0, 1, 2]
                ]
            ],
            dtype=torch.float32
        )

        dropout_p = 0.9999999
        dim = 0
        is_model_training = True

        result = pwF.sub_tensor_dropout(data_tensor, dropout_p, dim, is_model_training)

        self.assertListEqual(result[0].tolist(), result[1].tolist())