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

[rllib] Feature/histograms in tensorboard #6942

Merged
merged 5 commits into from
Jan 31, 2020

Conversation

roireshef
Copy link
Contributor

@roireshef roireshef commented Jan 28, 2020

Why are these changes needed?

Histograms are super powerful tool to use when the relevant information is hard to get compressed into a single scalar (in case one would be interested in the full distribution, for example).

Related issue number

Closes #4953

Checks

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@thavlik
Copy link

thavlik commented Jan 28, 2020

This is pretty exciting. We really need to get epsiode_reward_[min/max/mean] visualized with TB histograms.

For clarification (and so everyone else doesn't have to look at the code) histogram data is located under info['episode']['hist_data'], and we specify dict with each member being a float array? Example:

info['episode']['hist_data'] = {'my_histogram_data':[1.0, 0.5, 0.23, 0.4]}

Are deeply nested hist_data members supported? Does info['episode']['hist_data'] = {'my_nested':{'my_histogram_data':{[1.0, 0.5, 0.23, 0.4]}} show up as my_nested/my_histogram_data in TB?

Thank you!!

EDIT: It could also be useful to report training stats from tune.run with num_samples > 1 as TB histograms. Suppose you had a large number of trials with matching hparams, it would cleanly represent how the training dynamics change for the population over time.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/21115/
Test FAILed.

@roireshef
Copy link
Contributor Author

roireshef commented Jan 28, 2020

@thavlik no nesting here. info['episode'].hist_data[<metric_name>] expects a list of raw values, from which it will compute binned frequencies. See the example in the second commit. In the current implementation, I guess you could name the metric "my_nested/my_histogram_data" to get what you desire, but I haven't tried that.

@roireshef roireshef requested a review from ericl January 28, 2020 20:27
Copy link
Contributor

@richardliaw richardliaw left a comment

Choose a reason for hiding this comment

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

Thanks for this change! cc @ericl take a look?

@ericl ericl self-assigned this Jan 28, 2020
@@ -221,12 +221,15 @@ def close(self):


def to_tf_values(result, path):
from tensorboardX.summary import make_histogram
Copy link
Contributor

Choose a reason for hiding this comment

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

@richardliaw we are using TBXLogger by default now right? So in Ray latest to_tf_values won't be called.

I think this logic should be moved to the TBXLogger class.

Copy link
Contributor

Choose a reason for hiding this comment

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

(we should also delete this old code).

Copy link
Contributor

Choose a reason for hiding this comment

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

@roireshef can you push this logic into the TBXLogger class?

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 think I got it right, but can't test because I can't get this version to run inside my docker container yet (see #6662). It might take me a while to figure out, so I'd be glad to get your help testing it if you could...

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/21166/
Test PASSed.

@ericl
Copy link
Contributor

ericl commented Jan 30, 2020

This looks great! Just tried it out (also pushed a commit to record histograms for the episode stats by default):

image

@ericl
Copy link
Contributor

ericl commented Jan 30, 2020

Looks good pending test run.

@ericl ericl changed the title Feature/histograms in tensorboard [rllib] Feature/histograms in tensorboard Jan 30, 2020
@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/21176/
Test FAILed.

@ericl ericl merged commit dc7a555 into ray-project:master Jan 31, 2020
@roireshef
Copy link
Contributor Author

Glad you like it! Be sure to checkout the Histogram tab as well. I found it more interpretable than the Distribution one
Screenshot from 2020-02-01 12-05-33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[tune] Add support for histogram metric reporting
5 participants