def _save_times(times, parms): times = [{**{'output': parms['output']}, **times}] log_file = os.path.join('output_files', 'execution_times.csv') if not os.path.exists(log_file): open(log_file, 'w').close() if os.path.getsize(log_file) > 0: sup.create_csv_file(times, log_file, mode='a') else: sup.create_csv_file_header(times, log_file)
def _save_times(times, settings, temp_output): if times: times = [{**{'output': settings['output']}, **times}] log_file = os.path.join(temp_output, 'execution_times.csv') if not os.path.exists(log_file): open(log_file, 'w').close() if os.path.getsize(log_file) > 0: sup.create_csv_file(times, log_file, mode='a') else: sup.create_csv_file_header(times, log_file)
def on_train_end(self, logs={}): log_file = self.log_path data = [{ 'output_folder': self.output_folder, 'train_epochs': len(self.logs), 'avg_time': np.mean(self.logs), 'min_time': np.min(self.logs), 'max_time': np.max(self.logs) }] if os.path.exists(log_file): sup.create_csv_file(data, log_file, mode='a') else: sup.create_csv_file_header(data, log_file)
def _define_response(self, settings, status, sim_values, **kwargs) -> None: response = dict() measurements = list() data = { 'alg_manag': settings['alg_manag'], 'gate_management': settings['gate_management'], 'output': settings['output'] } # Miner parms if settings['mining_alg'] in ['sm1', 'sm3']: data['epsilon'] = settings['epsilon'] data['eta'] = settings['eta'] elif settings['mining_alg'] == 'sm2': data['concurrency'] = settings['concurrency'] else: raise ValueError(settings['mining_alg']) similarity = 0 # response['params'] = settings response['output'] = settings['output'] if status == STATUS_OK: similarity = np.mean([x['sim_val'] for x in sim_values]) loss = (1 - similarity) response['loss'] = loss response['status'] = status if loss > 0 else STATUS_FAIL for sim_val in sim_values: measurements.append({ **{ 'similarity': sim_val['sim_val'], 'sim_metric': sim_val['metric'], 'status': response['status'] }, **data }) else: response['status'] = status measurements.append({ **{ 'similarity': 0, 'sim_metric': 'dl', 'status': response['status'] }, **data }) if os.path.getsize(self.file_name) > 0: sup.create_csv_file(measurements, self.file_name, mode='a') else: sup.create_csv_file_header(measurements, self.file_name) return response
def _define_response(self, parms, loss, **kwargs) -> None: measurements = list() measurements.append({ 'loss': loss, 'sim_metric': 'val_loss', 'n_size': parms['n_size'], 'l_size': parms['l_size'], 'lstm_act': parms['lstm_act'], 'dense_act': parms['dense_act'], 'optim': parms['optim'], 'output': parms['output'][len(os.getcwd()) + 1:] }) if os.path.getsize(self.res_files) > 0: sup.create_csv_file(measurements, self.res_files, mode='a') else: sup.create_csv_file_header(measurements, self.res_files)
def _define_response(self, parms, status, loss, **kwargs) -> None: print(loss) response = dict() measurements = list() data = { 'n_size': parms['n_size'], 'l_size': parms['l_size'], 'lstm_act': parms['lstm_act'], 'dense_act': parms['dense_act'], 'optim': parms['optim'], 'scale_args': parms['scale_args'], 'output': parms['output'] } response['output'] = parms['output'] if status == STATUS_OK: response['loss'] = loss response['status'] = status if loss > 0 else STATUS_FAIL measurements.append({ **{ 'loss': loss, 'sim_metric': 'val_loss', 'status': response['status'] }, **data }) else: response['status'] = status measurements.append({ **{ 'loss': 1, 'sim_metric': 'val_loss', 'status': response['status'] }, **data }) if os.path.getsize(self.file_name) > 0: sup.create_csv_file(measurements, self.file_name, mode='a') else: sup.create_csv_file_header(measurements, self.file_name) return response