Create a csv for logging information :param log_name: The name of the log. The log filename will be .csv. :param key_name: The name of the attribute that is used as key (e.g. epoch number) :param value_names: The names of the attributes that are logged
(self, log_name: str, key_name: str, *value_names)
| 44 | f.write(msg+"\n") |
| 45 | |
| 46 | def create_log(self, log_name: str, key_name: str, *value_names): |
| 47 | """ |
| 48 | Create a csv for logging information |
| 49 | :param log_name: The name of the log. The log filename will be <log_name>.csv. |
| 50 | :param key_name: The name of the attribute that is used as key (e.g. epoch number) |
| 51 | :param value_names: The names of the attributes that are logged |
| 52 | """ |
| 53 | if log_name in self._logs.keys(): |
| 54 | raise Exception('Log already exists!') |
| 55 | # Add to existing logs |
| 56 | self._logs[log_name] = (key_name, value_names) |
| 57 | # Create log file. Create columns |
| 58 | with open(self.log_dir + f'/{log_name}.csv', 'w') as f: |
| 59 | f.write(','.join((key_name,) + value_names) + '\n') |
| 60 | |
| 61 | def log_values(self, log_name, key, *values): |
| 62 | """ |
no outgoing calls
no test coverage detected