Skip to content

Commit c04cb15

Browse files
committed
docs(easy_log): add documents
1 parent efce92e commit c04cb15

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

RLA/easy_log/complex_data_recorder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def pretty_plot_wrapper(cls, name:str, plot_func:Callable,
5454
:param title: title of the plotted figure
5555
:type title: str
5656
:param add_timestamp: add the timestamp (recorded by the timestep holder) to the name.
57-
:type add_timestamp: str
57+
:type add_timestamp: bool
5858
:param args: other parameters to plt.savefig
5959
:type args:
6060
:param kwargs: other parameters to plt.savefig

RLA/easy_log/logger.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,16 @@ def timestep():
406406
ma_dict = {}
407407

408408

409-
def ma_record_tabular(key, val, record_len, ignore_nan=False, exclude:Optional[Union[str, Tuple[str, ...]]]=None, freq:Optional[int]=None):
409+
def ma_record_tabular(key, val, record_len:[int], ignore_nan=False, exclude:Optional[Union[str, Tuple[str, ...]]]=None, freq:Optional[int]=None):
410+
"""
411+
Moving Averaged log recorder
412+
:param key: save to log this key
413+
:param val: save to log this value
414+
:param record_len: sliding window size for averaged value computation
415+
:param ignore_nan: ignore the nan value or not
416+
:param exclude: exclude to save the log to some types of logger (e.g., 'stdout', 'log', 'json', 'csv' or 'tensorboard')
417+
:param freq: the log will be dumped only after the timestep gap (holden by the time_step_holder) of recording is larger than freq.
418+
"""
410419
if key not in ma_dict:
411420
ma_dict[key] = deque(maxlen=record_len)
412421
if ignore_nan:
@@ -428,6 +437,9 @@ def logkv(key, val, exclude:Optional[Union[str, Tuple[str, ...]]]=None, freq:Opt
428437
429438
:param key: (Any) save to log this key
430439
:param val: (Any) save to log this value
440+
:param exclude: exclude to save the log to some types of logger (e.g., 'stdout', 'log', 'json', 'csv' or 'tensorboard')
441+
:param freq: the log will be dumped only after the timestep gap (holden by the time_step_holder) of recording is larger than freq.
442+
431443
"""
432444
if key not in lst_print_dict:
433445
lst_print_dict[key] = -np.inf
@@ -629,6 +641,9 @@ def logkv(self, key, val, exclude:Optional[Union[str, Tuple[str, ...]]]=None):
629641
630642
:param key: (Any) save to log this key
631643
:param val: (Any) save to log this value
644+
:param exclude: exclude to save the log to some types of logger (e.g., 'stdout', 'log', 'json', 'csv' or 'tensorboard')
645+
:param freq: the log will be dumped only after the timestep gap (holden by the time_step_holder) of recording is larger than freq.
646+
632647
"""
633648
self.name2val[key] = val
634649
self.exclude_name[key] = exclude

test/test_proj/proj/test_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def test_log_torch(self):
115115
logger.record_tabular("y_out-long", np.mean(y), freq=25)
116116
def plot_func():
117117
import matplotlib.pyplot as plt
118+
# plt.switch_backend('agg')
118119
testX = np.repeat(np.expand_dims(np.arange(-10, 10, 0.1), axis=-1), repeats=kwargs["input_size"], axis=-1)
119120
testX = testX.astype(np.float32)
120121
testY = target_func(testX)

0 commit comments

Comments
 (0)