Exemplo n.º 1
0
 def __determineInitialModelUID(self):
     sFiles = Storage.GetFilesSorted(self.RunSub.ArchitectureCommonFolder)
     sUID = None
     for sFile in sFiles:
         if sFile.startswith("initial-model_"):
             _, sName, _ = Storage.SplitFileName(sFile)
             sUID = sName[-12:]
     # A standard fold number 1 and the last saved initial experiment in the common folder will be returned
     return sUID
Exemplo n.º 2
0
    def ListCompressedModels(self):
        sResult = []

        if Storage.IsExistingPath(self.ExperimentModelFolder):
            sModelZipFiles = Storage.GetFilesSorted(self.ExperimentModelFolder)
            for sZipFile in sModelZipFiles:
                sZipFile = Storage.JoinPath(self.ExperimentModelFolder,
                                            sZipFile)
                sResult.append(sZipFile)

        return sResult
Exemplo n.º 3
0
    def ListSavedResults(self):
        if Storage.IsExistingPath(self.ExperimentResultsFolder):
            sModelResultFiles = Storage.GetFilesSorted(
                self.ExperimentResultsFolder)

        oModelResults = []
        for sResultFile in sModelResultFiles:
            _, sFileName, _ = Storage.SplitFileName(sResultFile)
            nEpochNumber = int(sFileName)
            oModelResults.append([nEpochNumber, sResultFile, None])

        return oModelResults
Exemplo n.º 4
0
    def GetNextConfigToEvaluate(self):
        sFiles = Storage.GetFilesSorted(self.ToEvaluteFolder)
        sConfigFiles = []
        for sFile in sFiles:
            _, _, sExt = Storage.SplitFileName(sFile)
            if sExt == ".cfg":
                sConfigFiles.append(
                    Storage.JoinPath(self.ToEvaluteFolder, sFile))

        if len(sFiles) > 0:
            sResult = sConfigFiles[0]
        else:
            sResult = None

        return sResult
Exemplo n.º 5
0
    def ListSavedModels(self):
        sModelFolders = []
        if Storage.IsExistingPath(self.ExperimentModelFolder):
            if not Storage.IsFolderEmpty(self.ExperimentModelFolder):
                sModelFolders = Storage.GetDirectoriesSorted(
                    self.ExperimentModelFolder)

        oModels = []
        for sModel in sModelFolders:
            sFolder = Storage.JoinPath(self.ExperimentModelFolder, sModel)
            sModelFiles = Storage.GetFilesSorted(sFolder)
            nEpochNumber = int(sModel)
            oModels.append([nEpochNumber, sFolder, sModelFiles])

        return oModels
Exemplo n.º 6
0
    def GetConfig(cls, p_sFolder):
        oResult = None

        sFolder = Storage.JoinPath(p_sFolder, "config")
        if Storage.IsExistingPath(sFolder):
            sFileList = Storage.GetFilesSorted(sFolder)
            sFileName = None
            for sItem in sFileList:
                if sItem.startswith("learn-config-used"):
                    sFileName = Storage.JoinPath(sFolder, sItem)
                    break

            if sFileName is not None:
                oResult = NNLearnConfig()
                oResult.LoadFromFile(sFileName)
                oResult.ParseUID()
        return oResult
Exemplo n.º 7
0
    def GetNextConfig(self):
        # By priority first evaluates models to save disk space and then start training
        sResult = self.GetNextConfigToEvaluate()

        if sResult is None:
            sFiles = Storage.GetFilesSorted(self.PendingFolder)
            sConfigFiles = []
            for sFile in sFiles:
                _, _, sExt = Storage.SplitFileName(sFile)
                if sExt == ".cfg":
                    sConfigFiles.append(
                        Storage.JoinPath(self.PendingFolder, sFile))

            if len(sFiles) > 0:
                sResult = sConfigFiles[0]
            else:
                sResult = None

        return sResult
Exemplo n.º 8
0
    def __listFiles(self):
        sEvaluationResultFiles = Storage.GetFilesSorted(self.Folder)
        self.FileNames = []
        self.ResultFiles = []
        for sFile in sEvaluationResultFiles:
            sFileNameFull = Storage.JoinPath(self.Folder, sFile)
            self.FileNames.append(sFileNameFull)
            self.ResultFiles.append([sFile, sFileNameFull])

        nFileCount = len(self.ResultFiles)

        self.EpochNumber = np.zeros((nFileCount), np.float32)
        self.Accuracy = np.zeros((nFileCount), np.float32)
        self.Recall = np.zeros((nFileCount), np.float32)
        self.Precision = np.zeros((nFileCount), np.float32)
        self.F1Score = np.zeros((nFileCount), np.float32)
        self.Points = np.zeros((nFileCount), np.float32)
        self.CrossF1Score = np.zeros((nFileCount), np.float32)
        self.ObjectiveF1Score = np.zeros((nFileCount), np.float32)
        self.PositiveF1Score = np.zeros((nFileCount), np.float32)