Skip to content

ignite_record_keeper_logger

IgniteRecordKeeperLogger

Uses record-keeper to record data tensorboard, csv, and sqlite.

Source code in pytorch_adapt\frameworks\ignite\loggers\ignite_record_keeper_logger.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class IgniteRecordKeeperLogger:
    """
    Uses [record-keeper](https://github.com/KevinMusgrave/record-keeper)
    to record data tensorboard, csv, and sqlite.
    """

    def __init__(
        self,
        folder=None,
        tensorboard_writer=None,
        record_writer=None,
        attr_list_names=None,
    ):
        """
        Arguments:
            folder: path where records will be saved.
            tensorboard_writer:
            record_writer: a ```RecordWriter``` object (see record-keeper)
        """
        from record_keeper import RecordKeeper, RecordWriter
        from torch.utils.tensorboard import SummaryWriter

        tensorboard_writer = c_f.default(
            tensorboard_writer,
            SummaryWriter,
            {"log_dir": folder, "max_queue": 1000000, "flush_secs": 30},
        )
        record_writer = c_f.default(record_writer, RecordWriter, {"folder": folder})
        attr_list_names = c_f.default(
            attr_list_names, pml_cf.list_of_recordable_attributes_list_names()
        )
        self.record_keeper = RecordKeeper(
            tensorboard_writer=tensorboard_writer,
            record_writer=record_writer,
            attributes_to_search_for=attr_list_names,
        )

    def add_training(self, adapter):
        def fn(engine):
            record_these = [
                ({"engine_output": engine.state.output}, {}),
                (
                    adapter.optimizers,
                    {
                        "parent_name": "optimizers",
                        "custom_attr_func": optimizer_attr_func,
                    },
                ),
                ({"misc": adapter.misc}, {}),
                (
                    {"hook": adapter.hook},
                    {"recursive_types": [BaseHook, BaseWeighter, torch.nn.Module]},
                ),
            ]
            for record, kwargs in record_these:
                self.record_keeper.update_records(
                    record, engine.state.iteration, **kwargs
                )

        return fn

    def add_validation(self, data, epoch):
        self.record_keeper.update_records(data, epoch)

    def write(self, engine):
        self.record_keeper.save_records()
        self.record_keeper.tensorboard_writer.flush()

__init__(folder=None, tensorboard_writer=None, record_writer=None, attr_list_names=None)

Parameters:

Name Type Description Default
folder

path where records will be saved.

None
tensorboard_writer None
record_writer

a RecordWriter object (see record-keeper)

None
Source code in pytorch_adapt\frameworks\ignite\loggers\ignite_record_keeper_logger.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def __init__(
    self,
    folder=None,
    tensorboard_writer=None,
    record_writer=None,
    attr_list_names=None,
):
    """
    Arguments:
        folder: path where records will be saved.
        tensorboard_writer:
        record_writer: a ```RecordWriter``` object (see record-keeper)
    """
    from record_keeper import RecordKeeper, RecordWriter
    from torch.utils.tensorboard import SummaryWriter

    tensorboard_writer = c_f.default(
        tensorboard_writer,
        SummaryWriter,
        {"log_dir": folder, "max_queue": 1000000, "flush_secs": 30},
    )
    record_writer = c_f.default(record_writer, RecordWriter, {"folder": folder})
    attr_list_names = c_f.default(
        attr_list_names, pml_cf.list_of_recordable_attributes_list_names()
    )
    self.record_keeper = RecordKeeper(
        tensorboard_writer=tensorboard_writer,
        record_writer=record_writer,
        attributes_to_search_for=attr_list_names,
    )