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

Add patch_tensorboard #204

Closed
wants to merge 1 commit into from
Closed

Add patch_tensorboard #204

wants to merge 1 commit into from

Conversation

daavoo
Copy link
Contributor

@daavoo daavoo commented Dec 30, 2021


Add patch_tensorboard function.

It can override or extend existing tensorboard logging calls by redirecting those to Live.log/Live.log_image calls.

This allows to patch both raw tensorboard calls but also existing callbacks using tensorboard:

from dvclive.tensorboard import patch_tensorboard
 
patch_tensorboard()

. . .
model.fit(
    x,
    y,
    epochs=2,
    callbacks=[tf.keras.callbacks.TensorBoard()],
)

patch_tensorboard(override=False) would generate DVCLive outputs while preserving the original behavior.

@daavoo daavoo self-assigned this Dec 30, 2021
@daavoo daavoo marked this pull request as draft January 3, 2022 12:25
@dberenbaum dberenbaum mentioned this pull request Feb 10, 2022
@daavoo daavoo force-pushed the tensorboard-patch branch 5 times, most recently from 2acd41c to c6458e3 Compare February 10, 2022 21:11
@daavoo daavoo marked this pull request as ready for review February 10, 2022 21:17
@daavoo daavoo requested review from dberenbaum and pared February 10, 2022 21:18


def patch_tensorboard(override: bool = True, **kwargs):
live = Live(**kwargs)
Copy link
Contributor Author

@daavoo daavoo Feb 10, 2022

Choose a reason for hiding this comment

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

Not sure if patch_tensorboard should instead optionally accept a Live instance

@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2022

Codecov Report

Merging #204 (c6458e3) into main (8471869) will decrease coverage by 0.01%.
The diff coverage is 92.20%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #204      +/-   ##
==========================================
- Coverage   91.07%   91.05%   -0.02%     
==========================================
  Files          19       19              
  Lines         605      671      +66     
==========================================
+ Hits          551      611      +60     
- Misses         54       60       +6     
Impacted Files Coverage Ξ”
dvclive/tensorboard.py 82.85% <82.85%> (ΓΈ)
dvclive/data/base.py 88.40% <100.00%> (+1.96%) ⬆️
dvclive/data/image.py 95.55% <100.00%> (+1.11%) ⬆️
dvclive/data/scalar.py 98.18% <100.00%> (+0.62%) ⬆️
dvclive/__init__.py

Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update 8471869...c6458e3. Read the comment docs.

assert "epoch_accuracy" in logs
assert len(logs["epoch_accuracy"]) == 2

for patch in patches:
Copy link
Contributor

Choose a reason for hiding this comment

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

So in case of using dvclive with tensorboard we would need to revert the patches after the execution in order to not use modified tensorboard later in our project?

Shouldn't patch_tensorboard be a context manager that would revert the patch after exiting the context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to test it but I think that the patch doesn't persist across python executions.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about the same process? I think safest way would be to let the user control when the dvclive is patching the tensorboard.

Support TensorFlow tensors in scalar and image data.
@dberenbaum
Copy link
Collaborator

Discussed with @daavoo that we will hold off on merging this.

@daavoo daavoo closed this Mar 10, 2022
@daavoo daavoo deleted the tensorboard-patch branch April 20, 2022 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants