예제 #1
0
    def __sequenceFoldNumber(self, p_sSourceFileName, p_nFoldSequence,
                             p_nCounter):
        print("  -> Sequencing fold numbers from template")
        sResult = []
        nCounter = p_nCounter
        for nFoldNumber in p_nFoldSequence:
            oNewConfig = NNLearnConfig()
            oNewConfig.LoadFromFile(p_sSourceFileName)
            oNewConfig.FoldNumber = nFoldNumber
            _, sName, _ = Storage.SplitFileName(p_sSourceFileName)
            sDestFileName = Storage.JoinFileName(
                self.PendingFolder,
                "%.3d-" % p_nCounter + sName + "-fold%d" % nFoldNumber, ".cfg")
            sResult.append(sDestFileName)
            oNewConfig.SaveToFile(sDestFileName)
            nCounter += 1

        return nCounter, sResult
예제 #2
0
    def __sequenceLearningRate(self, p_sSourceFileName,
                               p_nLearningRateSequence, p_nCounter):
        print("  -> Sequencing learning rates from template")
        sResult = []
        nCounter = p_nCounter
        for nLearningRate in p_nLearningRateSequence:
            oNewConfig = NNLearnConfig()
            oNewConfig.LoadFromFile(p_sSourceFileName)
            oNewConfig.Learn.LearningRate = nLearningRate
            _, sName, _ = Storage.SplitFileName(p_sSourceFileName)
            sDestFileName = Storage.JoinFileName(
                self.PendingFolder,
                "%.3d-" % p_nCounter + sName + "-lr%.6f" % nLearningRate,
                ".cfg")
            sResult.append(sDestFileName)
            oNewConfig.SaveToFile(sDestFileName)
            nCounter += 1

        return nCounter, sResult
예제 #3
0
    def AddConfig(self, p_sConfigFileName=None):
        if p_sConfigFileName is None:
            sSourceFileName = self.TemplateConfigFileName
        else:
            sSourceFileName = p_sConfigFileName
        _, sName, _ = Storage.SplitFileName(sSourceFileName)

        # Gets the current run/evaluation counter
        nCounter = self.__readCounter()

        oConfig = NNLearnConfig()
        oConfig.LoadFromFile(sSourceFileName)

        sDestFileNames = None
        if oConfig.LearningRateSequence is not None:
            nCounter, sDestFileNames = self.__sequenceLearningRate(
                sSourceFileName, oConfig.LearningRateSequence, nCounter)
        elif oConfig.FoldSequence is not None:
            nCounter, sDestFileNames = self.__sequenceFoldNumber(
                sSourceFileName, oConfig.FoldSequence, nCounter)
#             for nFoldNumber in oConfig.FoldSequence:
#                 oNewConfig = NNLearnConfig()
#                 oNewConfig.LoadFromFile(sSourceFileName)
#                 oNewConfig.FoldNumber = nFoldNumber
#                 sDestFileName = Storage.JoinFileName(self.PendingFolder, "%.3d-" % nCounter + sName, ".cfg")
#                 oNewConfig.SaveToFile(sDestFileName)
#                 nCounter += 1
        else:
            sDestFileNames = [
                Storage.JoinFileName(self.PendingFolder,
                                     "%.3d-" % nCounter + sName, ".cfg")
            ]
            Storage.CopyFile(sSourceFileName, sDestFileNames[0])
            nCounter += 1

        # Saves the current run/evaluation counter
        self.__writeCounter()

        return sDestFileNames