Beispiel #1
0
    def _print_message(self, header: str, data: Data, log_epoch: bool = False) -> None:
        """Print a log message to the screen, and record the `data` into the `system` summary.

        Args:
            header: The prefix for the log message.
            data: A collection of data to be recorded.
            log_epoch: Whether epoch information should be included in the log message.
        """
        log_message = header
        if log_epoch:
            log_message += "epoch: {}; ".format(self.system.epoch_idx)
            self.system.write_summary('epoch', self.system.epoch_idx)
        deferred = []
        for key, val in humansorted(data.read_logs().items(), key=lambda x: x[0]):
            if isinstance(val, ValWithError):
                log_message += "{}: {}; ".format(key, str(val))
            else:
                val = to_number(val)
                if val.size > 1:
                    deferred.append("\n{}:\n{};".format(key, np.array2string(val, separator=',')))
                else:
                    log_message += "{}: {}; ".format(key, str(val))
            self.system.write_summary(key, val)
        log_message = log_message.strip()
        for elem in deferred:
            log_message += elem
        print(log_message)
Beispiel #2
0
    def on_epoch_end(self, data: Data) -> None:
        tmpdic = defaultdict()
        tmpdic["mode"] = self.system.mode
        tmpdic["step"] = self.system.global_step
        tmpdic["epoch"] = self.system.epoch_idx

        if "*" in self.inputs:
            for key, value in data.read_logs().items():
                tmpdic[key] = value
                if key not in self.df.columns:
                    self.df[key] = ''
        else:
            for key in self.inputs:
                tmpdic[key].append(data[key])
                if key not in self.df.columns:
                    self.df[key] = ''
        for col in self.df.columns:
            if col not in tmpdic.keys():
                tmpdic[col] = ''

        self.df = self.df.append(tmpdic, ignore_index=True)
Beispiel #3
0
    def _print_message(self,
                       header: str,
                       data: Data,
                       log_epoch: bool = False) -> None:
        """Print a log message to the screen, and record the `data` into the `system` summary.

        Args:
            header: The prefix for the log message.
            data: A collection of data to be recorded.
            log_epoch: Whether epoch information should be included in the log message.
        """
        log_message = header
        if log_epoch:
            log_message += "epoch: {}; ".format(self.system.epoch_idx)
            self.system.write_summary('epoch', self.system.epoch_idx)
        for key, val in data.read_logs().items():
            val = to_number(val)
            self.system.write_summary(key, val)
            if val.size > 1:
                log_message += "\n{}:\n{};".format(
                    key, np.array2string(val, separator=','))
            else:
                log_message += "{}: {}; ".format(key, str(val))
        print(log_message)