예제 #1
0
    def get_metadata_protobuf(self) -> explanation_metadata.ExplanationMetadata:
        """Returns the current metadata as a Protobuf object.

        Returns:
            ExplanationMetadata object format of the explanation metadata.
        """
        return explanation_metadata.ExplanationMetadata(
            inputs=self._inputs, outputs=self._outputs,
        )
    def test_get_metadata_protobuf_sequential(self):
        self._set_up_sequential()

        builder = saved_model_metadata_builder.SavedModelMetadataBuilder(
            self.saved_model_path
        )
        generated_object = builder.get_metadata_protobuf()
        expected_object = explanation_metadata.ExplanationMetadata(
            inputs={"dense_input": {"input_tensor_name": "dense_input"}},
            outputs={"dense_2": {"output_tensor_name": "dense_2"}},
        )
        assert expected_object == generated_object
예제 #3
0
    def test_get_metadata_protobuf_correct_inputs(self):
        self._set_up()
        md_builder = saved_model_metadata_builder.SavedModelMetadataBuilder(
            self.model_path, tags=[tf.saved_model.tag_constants.SERVING])
        expected_object = explanation_metadata.ExplanationMetadata(
            inputs={"x": {
                "input_tensor_name": "inp:0"
            }},
            outputs={"y": {
                "output_tensor_name": "Relu:0"
            }},
        )

        assert md_builder.get_metadata_protobuf() == expected_object
예제 #4
0
    def test_get_metadata_protobuf_double_output(self):
        self._set_up()
        md_builder = saved_model_metadata_builder.SavedModelMetadataBuilder(
            self.model_path,
            signature_name="double",
            outputs_to_explain=["lin"])

        expected_object = explanation_metadata.ExplanationMetadata(
            inputs={"x": {
                "input_tensor_name": "inp:0"
            }},
            outputs={"lin": {
                "output_tensor_name": "Add:0"
            }},
        )

        assert md_builder.get_metadata_protobuf() == expected_object