feat: add basic explain get_metadata function for tf2. #507
Merged
ji-yaqi merged 22 commits intogoogleapis:masterfrom Jul 8, 2021
Merged
feat: add basic explain get_metadata function for tf2. #507ji-yaqi merged 22 commits intogoogleapis:masterfrom
ji-yaqi merged 22 commits intogoogleapis:masterfrom
Conversation
Contributor
Author
|
/hold |
Contributor
Author
|
/unhold |
sasha-gitg
requested changes
Jun 29, 2021
| self, | ||
| model_path: str, | ||
| signature_name: Optional[str] = None, | ||
| outputs_to_explain: Optional[List[str]] = (), |
Member
There was a problem hiding this comment.
This Optional type is a List while the default is an empty tuple. It seems like the default can be None instead.
google/cloud/aiplatform/explain/metadata/tf/v2/saved_model_metadata_builder.py
Show resolved
Hide resolved
Comment on lines
104
to
115
| if tensor_spec.dtype.is_floating: | ||
| input_mds[ | ||
| name | ||
| ] = explanation_metadata.ExplanationMetadata.InputMetadata( | ||
| input_tensor_name=name | ||
| ) | ||
| else: | ||
| input_mds[ | ||
| name | ||
| ] = explanation_metadata.ExplanationMetadata.InputMetadata( | ||
| input_tensor_name=name, modality="categorical", | ||
| ) |
Member
There was a problem hiding this comment.
Option to reduce the size of this block.
Suggested change
| if tensor_spec.dtype.is_floating: | |
| input_mds[ | |
| name | |
| ] = explanation_metadata.ExplanationMetadata.InputMetadata( | |
| input_tensor_name=name | |
| ) | |
| else: | |
| input_mds[ | |
| name | |
| ] = explanation_metadata.ExplanationMetadata.InputMetadata( | |
| input_tensor_name=name, modality="categorical", | |
| ) | |
| input_mds[name] = explanation_metadata.ExplanationMetadata.InputMetadata( | |
| input_tensor_name=name, | |
| modality=None if tensor_spec.dtype.is_floating else "categorical" | |
| ) |
setup.py
Outdated
| tensorboard_extra_require = ["tensorflow >=2.3.0, <=2.5.0"] | ||
| metadata_extra_require = ["pandas >= 1.0.0"] | ||
| full_extra_require = tensorboard_extra_require + metadata_extra_require | ||
| xai_extra_require = ["tensorflow-cpu>=2.3.0, <=2.5.0"] |
Member
There was a problem hiding this comment.
"tensorflow" is the CPU-only release: https://www.tensorflow.org/install/pip
This will also make it easier to manage with TB's TF dependency.
setup.py
Outdated
| metadata_extra_require = ["pandas >= 1.0.0"] | ||
| full_extra_require = tensorboard_extra_require + metadata_extra_require | ||
| xai_extra_require = ["tensorflow-cpu>=2.3.0, <=2.5.0"] | ||
| full_extra_require = ( |
Member
There was a problem hiding this comment.
tensorboard and xai have the same dependencies so we may need to deduplicate this with list(set(...)).
|
|
||
|
|
||
| class SavedModelMetadataBuilderTest(tf.test.TestCase): | ||
| def _set_up(self): |
Member
There was a problem hiding this comment.
Since this is only used by one test, it should perhaps not be a shared method.
sasha-gitg
approved these changes
Jul 8, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Basic explain get_metadata function, for tf2.
Usage:
The main difference from Vertex SDK and XAI SDK's
get_metadatafunction:In Vertex SDK, users the camelCase while in XAI, variables users snake_case
e.g. Vertex:
inputTensorName, XAI:input_tensor_nameIf modality and encoding in inputs are not set, XAI SDK populates the default:
Vertex SDK doesn't populate the default values. It only populates the users's settings.
The two methods will not make any difference in the actual settings.