Ejemplo n.º 1
0
    def _testing_original_file(self, test_dir, type_data):
        dnn_predict_dir = (
            "/home/danglab/3P/Net_Space/unnormal/"
            + self.hidden_layer
            + "100ms/"
            + self.artic
            + type_data
            + "test_"
            + str(self.test_number)
            + "/"
        )

        if not os.path.exists(dnn_predict_dir):
            os.makedirs(dnn_predict_dir)

        for afile in self.missing_filename_list:
            test_arr, factors = read_file_test(
                test_dir + afile + "_in.txt", self.n_input_f, "factors"
            )  # read a missing_feature
            energy = test_arr[:, 0]  # ko cho energy vao DNN
            test_arr = test_arr[:, 1 : self.n_input_f]
            factors = 1

            self._write_predict_2_file(
                dnn_predict_dir + afile + ".txt", energy, self.predict(test_arr), factors
            )  # write result to file
Ejemplo n.º 2
0
    def _testing_noise_space(self, test_dir, type_data):
        for type_test in sorted(os.listdir(test_dir)):
            if (not type_test.endswith("zip")) and "output" not in type_test:
                type_test_dir = test_dir + type_test + "/"
                print type_test_dir
                dnn_predict_dir = (
                    "/home/danglab/3P/Net_Space/unnormal/"
                    + self.hidden_layer
                    + "100ms/"
                    + self.artic
                    + type_data
                    + "test_"
                    + str(self.test_number)
                    + "/"
                    + type_test
                    + "/"
                )

                if not os.path.exists(dnn_predict_dir):
                    os.makedirs(dnn_predict_dir)
                print type_test
                duration = type_test.split("_")[1]  # 50ms, 100ms

                # listtest = sorted(os.listdir(type_test_dir))
                # for afile in listtest:
                for prefix_file in self.missing_filename_list:
                    afile = prefix_file + "_" + duration + "_in.txt"
                    test_arr, factors = read_file_test(
                        type_test_dir + afile, self.n_input_f, "factors"
                    )  # read a missing_feature
                    find_ = [m.start() for m in re.finditer("_", afile)]
                    energy = test_arr[:, 0]  # ko cho energy vao DNN
                    test_arr = test_arr[:, 1 : self.n_input_f]
                    factors = 1
                    self._write_predict_2_file(
                        dnn_predict_dir + afile.replace(afile[find_[4] : len(afile) - 4], ""),
                        energy,
                        self.predict(test_arr),
                        factors,
                    )  # write result to file