示例#1
0
    def _exp_final_callback(self, job_end: float, exp_json: dict) -> dict:
        """Calculates the average test error from all partitions.

        :param job_end: Time of the job end.
        :param _: Catches additional callback arguments.

        :returns: The result in a dictionary.
        """

        experiment_json = {"state": "FINISHED"}
        final_result = self.result_dict

        util.finalize_experiment(
            exp_json,
            final_result[self.main_metric_key],
            self.app_id,
            self.run_id,
            experiment_json,
            self.duration,
            self.log_dir,
            None,
            None,
        )
        self.experiment_done = True
        self.prep_results(str(job_end))

        print("List of the results:\n")
        for key, value in final_result.items():
            print(key, " : ", value)
        print("Finished experiment. Total run time: " +
              util.time_diff(self.job_start, job_end))

        return {"test result": final_result}
    def _exp_final_callback(self, job_end: float, exp_json: dict) -> dict:
        """Calculates the average test error from all partitions.

        :param job_end: Time of the job end.
        :param _: Catches additional callback arguments.

        :returns: The result in a dictionary.
        """

        experiment_json = {"state": "FINISHED"}
        final_result = self.average_metric()

        util.finalize_experiment(
            exp_json,
            final_result,
            self.app_id,
            self.run_id,
            experiment_json,
            self.duration,
            self.log_dir,
            None,
            None,
        )
        self.experiment_done = True
        self.prep_results(str(job_end))

        print("Final average test loss: {:.3f}".format(final_result))
        print("Finished experiment. Total run time: " +
              util.time_diff(self.job_start, job_end))

        return {"test result": self.average_metric()}
示例#3
0
    def finalize(self, job_end: float) -> dict:
        """Saves a summary of the experiment to a dict and logs it in the DFS.

        :param job_end: Time of the job end.

        :returns: The experiment summary dict.
        """
        self.job_end = job_end
        self.duration = util.seconds_to_milliseconds(self.job_end -
                                                     self.job_start)
        duration_str = util.time_diff(self.job_start, self.job_end)
        results = self.prep_results(duration_str)
        print(results)
        self.log(results)
        EnvSing.get_instance().dump(
            json.dumps(self.result, default=util.json_default_numpy),
            self.log_dir + "/result.json",
        )
        EnvSing.get_instance().dump(self.json(), self.log_dir + "/maggy.json")
        return self.result_dict
示例#4
0
    def _exp_final_callback(self, job_end: float, _: Any) -> dict:
        """Calculates the average test error from all partitions.

        :param job_end: Time of the job end.
        :param _: Catches additional callback arguments.

        :returns: The result in a dictionary.
        """
        result = {"test result": self.average_metric()}
        exp_ml_id = str(self.app_id) + "_" + str(self.run_id)
        EnvSing.get_instance().attach_experiment_xattr(
            exp_ml_id,
            {"state": "FINISHED", "duration": int(job_end - self.job_start) * 1000},
            "FULL_UPDATE",
        )
        print("Final average test loss: {:.3f}".format(self.average_metric()))
        print(
            "Finished experiment. Total run time: "
            + util.time_diff(self.job_start, job_end)
        )
        return result