Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sanitize arrays when logging as hyperparameters in TensorBoardLogger #9031

Merged
merged 6 commits into from
Aug 24, 2021

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Aug 21, 2021

What does this PR do?

Fixes #9022

TensorBoardLogger can log hyperparameters but not all types of data. It can do arrays that are 1-dimensional but anything higher-dimensional not, so we will sanitize it by converting to string as we do with other unsupported types.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

I made sure I had fun coding 🙃

@awaelchli awaelchli added logger Related to the Loggers feature Is an improvement or enhancement labels Aug 22, 2021
@awaelchli awaelchli added this to the v1.5 milestone Aug 22, 2021
@codecov
Copy link

codecov bot commented Aug 22, 2021

Codecov Report

Merging #9031 (fc61804) into master (c8e9fb4) will decrease coverage by 4%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #9031    +/-   ##
=======================================
- Coverage      93%     89%    -4%     
=======================================
  Files         175     175            
  Lines       14457   14462     +5     
=======================================
- Hits        13406   12811   -595     
- Misses       1051    1651   +600     

@awaelchli awaelchli added bug Something isn't working and removed feature Is an improvement or enhancement labels Aug 22, 2021
@awaelchli awaelchli added feature Is an improvement or enhancement and removed bug Something isn't working labels Aug 22, 2021
@awaelchli awaelchli marked this pull request as ready for review August 22, 2021 00:27
@mergify mergify bot removed the has conflicts label Aug 23, 2021
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat !

@@ -286,6 +287,12 @@ def _get_next_version(self):

return max(existing_versions) + 1

@staticmethod
def _sanitize_params(params: Dict[str, Any]) -> Dict[str, Any]:
params = LightningLoggerBase._sanitize_params(params)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For later, should we move this out as a utility function? Are there opportunities for consolidation with other hyper parameter saving logic the framework has?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can but keep in mind not all loggers have the same level of support and flexibility so sanitization, flattening etc. is generally speaking always subject to the individual logger.

Are there opportunities for consolidation with other hyper parameter saving logic the framework has?

not any I know of

@mergify mergify bot added the ready PRs ready to be merged label Aug 24, 2021
@Borda Borda requested a review from justusschock August 24, 2021 07:06
@awaelchli awaelchli merged commit dfae734 into master Aug 24, 2021
@awaelchli awaelchli deleted the bugfix/sanitize-array branch August 24, 2021 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement logger Related to the Loggers ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logging tensors as hparam fails
5 participants