def _parse_verification_results(self, task_declaration: TaskDeclaration, finished_verification_assignments: ListVerificationAssignments): fake_workers = {} for va in finished_verification_assignments: assert va.verification_result.error is None for result in va.verification_result.result: if result['is_fake']: try: fake_workers[result['worker_id']] += 1 except KeyError: fake_workers[result['worker_id']] = 1 task_declaration.tflops += va.verification_result.tflops # what to do if many verifiers ? if va.verification_result.weights_ipfs: # if weights_ipfs is None than fake workers are present task_declaration.weights_ipfs = va.verification_result.weights_ipfs if task_declaration.last_iteration: task_declaration.loss = va.verification_result.loss task_declaration.accuracy = va.verification_result.accuracy logger.info('Copy summarization for {}, loss: {}, accuracy: {}'.format( task_declaration, task_declaration.loss, task_declaration.accuracy)) else: logger.info('Copy summarization for {}'.format(task_declaration)) return fake_workers
def _save_loss_and_accuracy(self, task_declaration: TaskDeclaration, finished_task_assignments): assert task_declaration.current_iteration > 1 loss = [] accuracy = [] # collect loss and accuracy for prev iteration iteration = str(task_declaration.current_iteration - 1) for ta in finished_task_assignments: if ta.train_result.eval_results is not None and ta.train_result.eval_results.get(iteration): loss.append(ta.train_result.eval_results[iteration]['loss']) accuracy.append(ta.train_result.eval_results[iteration]['accuracy']) assert len(loss) and len(accuracy) task_declaration.loss = sum(loss)/len(loss) task_declaration.accuracy = sum(accuracy)/len(accuracy) logger.info('Save avr iteration: {} loss: {} and accuracy: {}'.format( iteration, task_declaration.loss, task_declaration.accuracy))