-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PiperOrigin-RevId: 327014404 Change-Id: I84884cc9019064d2bb2be8556d4c794d78e14f34
- Loading branch information
1 parent
1b1d160
commit 7eeeb24
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Lint as: python3 | ||
# Copyright 2018 DeepMind Technologies Limited. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Acme specific utils.""" | ||
from acme.utils.loggers import base | ||
|
||
|
||
class ConstantLogger(base.Logger): | ||
"""Logger for values that remain constant throughout the experiment. | ||
This logger is used to log additional values e.g. level_name or | ||
hyperparameters that do not change in an experiment. Having these values | ||
allows to group or facet plots when analysing data post-experiment. | ||
""" | ||
|
||
def __init__(self, | ||
constant_data: base.LoggingData, | ||
to: base.Logger): | ||
"""Initialise the extra info logger. | ||
Args: | ||
constant_data: Dictionary containing the constant info to be logged. | ||
to: The logger to add these extra info to. | ||
""" | ||
self._constant_data = constant_data | ||
self._to = to | ||
|
||
def write(self, data: base.LoggingData): | ||
# Need to create a new mutable dictionary that will be updated with the data | ||
# we will be writing. base.LoggingData is immutable and hence cannot be | ||
# updated. | ||
self._to.write({**self._constant_data, **data}) |