コード例 #1
0
class TestTrainingModeForConvE(BaseTestTrainingMode):
    """Test that ConvE can be trained and evaluated correctly in training mode."""

    config = BaseTestTrainingMode.config
    config = set_training_mode_specific_parameters(config=config)
    config[pkc.KG_EMBEDDING_MODEL_NAME] = pkc.CONV_E_NAME
    config[pkc.EMBEDDING_DIM] = 50
    config[pkc.CONV_E_INPUT_CHANNELS] = 1
    config[pkc.CONV_E_OUTPUT_CHANNELS] = 3
    config[pkc.CONV_E_HEIGHT] = 5
    config[pkc.CONV_E_WIDTH] = 10
    config[pkc.CONV_E_KERNEL_HEIGHT] = 5
    config[pkc.CONV_E_KERNEL_WIDTH] = 3
    config[pkc.CONV_E_INPUT_DROPOUT] = 0.2
    config[pkc.CONV_E_FEATURE_MAP_DROPOUT] = 0.5
    config[pkc.CONV_E_OUTPUT_DROPOUT] = 0.5

    def test_training(self):
        """Test that ConvE is trained correctly in training mode."""
        results = self.execute_pipeline(config=self.config)
        self.check_training_mode_without_evaluation(results=results)

    def test_evaluation(self):
        """Test that ConvE is trained and evaluated correctly in training mode."""
        config = set_evaluation_specific_parameters(config=self.config)
        results = self.execute_pipeline(config=config)
        self.check_training_followed_by_evaluation(results=results)
コード例 #2
0
class TestHPOModeForERMLP(BaseTestTrainingMode):
    """Test that UM can be trained and evaluated correctly in HPO mode."""
    config = BaseTestTrainingMode.config
    config = set_training_mode_specific_parameters(config=config)
    config[pkc.KG_EMBEDDING_MODEL_NAME] = pkc.ERMLP_NAME
    config[pkc.EMBEDDING_DIM] = [10, 50]
    config[pkc.MARGIN_LOSS] = [1, 2]

    def test_hpo_mode(self):
        """Test whether HPO mode works correctly for ERMLP."""
        config = set_hpo_mode_specific_parameters(config=self.config)
        results = self.execute_pipeline(config=config)
        self.check_training_followed_by_evaluation(results=results)
コード例 #3
0
class TestHPOModeForTransE(BaseTestTrainingMode):
    """Test that TransE can be trained and evaluated correctly in HPO mode."""
    config = BaseTestTrainingMode.config
    config = set_training_mode_specific_parameters(config=config)
    config[pkc.KG_EMBEDDING_MODEL_NAME] = pkc.TRANS_E_NAME
    config[pkc.EMBEDDING_DIM] = [10, 20, 50]
    config[pkc.SCORING_FUNCTION_NORM] = [1, 2]
    config[pkc.NORM_FOR_NORMALIZATION_OF_ENTITIES] = [2]
    config[pkc.MARGIN_LOSS] = [1, 1.5, 2]

    def test_hpo_mode(self):
        """Test whether HPO mode works correctly for TransE."""
        config = set_hpo_mode_specific_parameters(config=self.config)
        results = self.execute_pipeline(config=config)
        self.check_training_followed_by_evaluation(results=results)
コード例 #4
0
class TestTrainingModeForERMLP(BaseTestTrainingMode):
    """Test that UM can be trained and evaluated correctly in training mode."""
    config = BaseTestTrainingMode.config
    config = set_training_mode_specific_parameters(config=config)
    config[pkc.KG_EMBEDDING_MODEL_NAME] = pkc.ERMLP_NAME
    config[pkc.EMBEDDING_DIM] = 50
    config[pkc.MARGIN_LOSS] = 1

    def test_training(self):
        """Test that ERMLP is trained correctly in training mode."""
        results = self.execute_pipeline(config=self.config)
        self.check_training_mode_without_evaluation(results=results)

    def test_evaluation(self):
        """Test that ERMLP is trained and evaluated correctly in training mode."""
        config = set_evaluation_specific_parameters(config=self.config)
        results = self.execute_pipeline(config=config)
        self.check_training_followed_by_evaluation(results=results)
        self.assertIsNotNone(results.results[pkc.FINAL_CONFIGURATION])
コード例 #5
0
class TestTrainingModeForRESCAL(BaseTestTrainingMode):
    """Test that RESCAL can be trained and evaluated correctly in training mode."""
    config = BaseTestTrainingMode.config
    config = set_training_mode_specific_parameters(config=config)
    config[pkc.KG_EMBEDDING_MODEL_NAME] = pkc.RESCAL_NAME
    config[pkc.EMBEDDING_DIM] = 50
    config[pkc.SCORING_FUNCTION_NORM] = 2  # corresponds to L2
    config[pkc.MARGIN_LOSS] = 1  # corresponds to L1

    def test_training(self):
        """Test that RESCAL is trained correctly in training mode."""
        results = self.execute_pipeline(config=self.config)
        self.check_training_mode_without_evaluation(results=results)

    def test_evaluation(self):
        """Test that RESCAL is trained and evaluated correctly in training mode."""
        config = set_evaluation_specific_parameters(config=self.config)
        results = self.execute_pipeline(config=config)
        self.check_training_followed_by_evaluation(results=results)
コード例 #6
0
class TestTrainingModeForTransE(BaseTestTrainingMode):
    """Test that TransE can be trained and evaluated correctly in training mode."""
    config = BaseTestTrainingMode.config
    config = set_training_mode_specific_parameters(config=config)
    config[pkc.KG_EMBEDDING_MODEL_NAME] = pkc.TRANS_E_NAME
    config[pkc.EMBEDDING_DIM] = 50
    config[pkc.SCORING_FUNCTION_NORM] = 1  # corresponds to L1
    config[pkc.NORM_FOR_NORMALIZATION_OF_ENTITIES] = 2  # corresponds to L2
    config[pkc.MARGIN_LOSS] = 1  # corresponds to L1

    def test_training(self):
        """Test that TransE is trained correctly in training mode."""
        results = self.execute_pipeline(config=self.config)
        self.check_training_mode_without_evaluation(results=results)

    def test_evaluation(self):
        """Test that TransE is trained and evaluated correctly in training mode."""
        config = set_evaluation_specific_parameters(config=self.config)
        results = self.execute_pipeline(config=config)
        self.check_training_followed_by_evaluation(results=results)
        self.assertIsNotNone(results.results[pkc.FINAL_CONFIGURATION])
コード例 #7
0
class TestHPOModeForConvE(BaseTestTrainingMode):
    """Test that ConvE can be trained and evaluated correctly in HPO mode."""

    config = BaseTestTrainingMode.config
    config = set_training_mode_specific_parameters(config=config)
    config[pkc.KG_EMBEDDING_MODEL_NAME] = pkc.CONV_E_NAME
    config[pkc.EMBEDDING_DIM] = [10, 50]
    config[pkc.CONV_E_INPUT_CHANNELS] = 1
    config[pkc.CONV_E_OUTPUT_CHANNELS] = [1, 3]
    config[pkc.CONV_E_HEIGHT] = [2, 5]
    config[pkc.CONV_E_WIDTH] = [5, 10]
    config[pkc.CONV_E_KERNEL_HEIGHT] = [1, 5]
    config[pkc.CONV_E_KERNEL_WIDTH] = [3, 8]
    config[pkc.CONV_E_INPUT_DROPOUT] = [0.2, 0.5]
    config[pkc.CONV_E_FEATURE_MAP_DROPOUT] = [0.2, 0.4]
    config[pkc.CONV_E_OUTPUT_DROPOUT] = [0.5]

    def test_hpo_mode(self):
        """Test whether HPO mode works correctly for ConvE."""
        config = set_hpo_mode_specific_parameters(config=self.config)
        results = self.execute_pipeline(config=config)
        self.check_training_followed_by_evaluation(results=results)