当前位置: 首页>>代码示例>>Python>>正文


Python NeuralNetwork.save方法代码示例

本文整理汇总了Python中NeuralNetwork.NeuralNetwork.save方法的典型用法代码示例。如果您正苦于以下问题:Python NeuralNetwork.save方法的具体用法?Python NeuralNetwork.save怎么用?Python NeuralNetwork.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NeuralNetwork.NeuralNetwork的用法示例。


在下文中一共展示了NeuralNetwork.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: train

# 需要导入模块: from NeuralNetwork import NeuralNetwork [as 别名]
# 或者: from NeuralNetwork.NeuralNetwork import save [as 别名]
def train(method, learningRate, momentum, numEpochs, output, samples, layers=None, minibatchsize=None):
    trainImages, trainOutput, trainNumbers = loadData('training', samples)
    nn = NeuralNetwork(layerCount=len(layers),
                       layerSize=np.array(layers),
                       actFunctions=np.array([1, 1]))

    trainmethod = {
        TRAININGMETHODS[0]: nn.trainBatch,
        TRAININGMETHODS[1]: nn.trainStochastic
    }
    errors = trainmethod[method](
        trainImages, trainOutput, learningRate=learningRate, momentum=momentum, numEpochs=numEpochs)
    # Error did happen, we just return, error message would be printed by the
    # train method
    if not errors or len(errors) == 0:
        return

    # print 'Training done, errors:', errors
    print 'Saving output to', output
    nn.save(output)
    print 'Testing...'
    test(nn)
开发者ID:crysxd,项目名称:Parallel-Computing-and-Algorithms-X033537-Project,代码行数:24,代码来源:nnet.py

示例2: AI

# 需要导入模块: from NeuralNetwork import NeuralNetwork [as 别名]
# 或者: from NeuralNetwork.NeuralNetwork import save [as 别名]

#.........这里部分代码省略.........
        self.lastCommand = "voir"


    def funcPrend(self):
        case = self.cases[0]
        if len(case) > 0:
            self.socket.sendData("prend " + case[0])
            case.remove(case[0])
        else:
            eprint("Impossible to execute 'prend' ")
        self.lastCommand = "prend"

    def funcExpulse(self):
        print ("Expulse ?")
        self.lastCommand = "prend"

    def funcIncantation(self):
        self.putResOnCase()
        self.socket.sendData("incantation")
        self.lastCommand = "incantation"

    def funcFork(self):
        print ("fork")
        self.lastCommand = "fork"


    def chooseAnAction(self):
        inputs = []
        inputs.append(self.life)
        inputs.append(self.level)
        inputs.append(self.freePlace)

        inputs.append(self.getCaseLevel(0))
        inputs.append(self.getCaseLevel(1))
        inputs.append(self.getCaseLevel(2))
        inputs.append(self.getCaseLevel(3))

        inputs.append(self.getCaseFood(0))
        inputs.append(self.getCaseFood(1))
        inputs.append(self.getCaseFood(2))
        inputs.append(self.getCaseFood(3))

        inputs.append(self.isLevelComplete())
        inputs.append(self.canIncant())

        print ("INPUTS:", inputs)
        actionValue = self.neuralNetwork.update(inputs)[0]
        actionChoosen = self.getRangeAction(actionValue)
        if actionChoosen == "":
            eprint("Error in value of the neuralNetwork:", actionValue)
        print (actionValue, "--->", actionChoosen)
        command = input("Command:")
        if command == "quit":
            self.neuralNetwork.save()
            sys.exit()
        elif command == "learn":
            pass #learn it
        Macro.CommandRef[actionChoosen](self)

    def updateInfo(self):
        message = ""
        self.socket.sendData("inventaire")
        while message == "":
            message = self.socket.selectData()
        self.life = int(message.replace("{", "").replace("}", "").split(",")[0].split(" ")[1])

    def initData(self, message):
        # TODO receive "{xx,xx,,,,}\n9\r\n  with voir + connect_nbr CHANGE PARSING
        message = message.split("\n")
        self.getCase(message[0])
        self.freePlace = int(message[1])
        return False

    def receiveMessage(self, message):
        if self.firstReceive is True:
            self.firstReceive = self.initData(message)
        elif message == "mort":
            return
        if self.lastCommand != "":
            if self.lastCommand == "voir" and message[0] == "{":
                self.getCase(message)
            self.lastCommand = ""
        print (time.strftime("%H:%M:%S"), ":", message)

    def run(self):

        self.createNeuralNetwork(False)
        while True:
            message = self.socket.selectData()
            if message:
                self.receiveMessage(message)
            if self.firstAction is True:
                self.socket.sendData("voir")
                self.socket.sendData("connect_nbr")
                self.firstAction = False
            if self.lastCommand == "" and  self.firstReceive is False:
                self.updateInfo()
                self.chooseAnAction()

            message = ""
开发者ID:Nyrii,项目名称:-EPITECH-Zappy,代码行数:104,代码来源:AI.py


注:本文中的NeuralNetwork.NeuralNetwork.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。