• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python networkreader.NetworkReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pybrain.tools.xml.networkreader.NetworkReader的典型用法代码示例。如果您正苦于以下问题:Python NetworkReader类的具体用法?Python NetworkReader怎么用?Python NetworkReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: loadFromFile

    def loadFromFile(self):
        try:
            if self.major:
                self.net = NetworkReader.readFrom(TRAINED_DATA_FILEPATH_MAJOR)
            else:
                self.net = NetworkReader.readFrom(TRAINED_DATA_FILEPATH_MINOR)

        except:
            print "Could not find or open file"
开发者ID:davepagurek,项目名称:Chordi.co,代码行数:9,代码来源:learn.py


示例2: usebp

def usebp():
    patterns = [

        [[3158, 3503, 3342, 644, 937, 750, 546, 503, 593], [4751]],
        [[3092, 3011, 3217, 675, 882, 881, 543, 598, 564], [4445]],
        [[3180, 3043, 3031, 785, 830, 799, 448, 517, 564], [4514]],
        [[3389, 3469, 3450, 794, 933, 804, 544, 556, 578], [4755]],
        [[3224, 3201, 3433, 904, 737, 772, 522, 591, 585], [4864]],
        [[3503, 3342, 3410, 937, 750, 725, 503, 593, 616], [4646]],
        [[3011, 3217, 3143, 882, 881, 701, 598, 564, 601], [0]],
        [[3043, 3031, 3209, 830, 799, 701, 517, 564, 604], [0]],
        [[3469, 3450, 3446, 933, 804, 756, 556, 578, 553], [0]],
        [[3201, 3433, 3436, 737, 772, 817, 591, 585, 611], [0]],
        [[3342, 3410, 3277, 750, 725, 837, 593, 616, 532], [0]],

    ]

    net = NetworkReader.readFrom('/home/wtq/BigData-MachineLearning/Bpnn/BusWorkNet.xml')
    for p in patterns:
        testInput = p[0]
        targetOut = p[1]
        testInput = tuple(map(lambda n: float(n) / 6000, testInput))
        out = net.activate(testInput)
        print"out->", (out * 6000)
        distance = list(map(lambda x: 6000 * x[0] - x[1], zip(out, targetOut)))
        print(distance)
开发者ID:wangtianqi1993,项目名称:MachineLearningComputation,代码行数:26,代码来源:PackBp.py


示例3: __init__

 def __init__(self, port=None, baud=115200):
     print("connecting to OpenBCI...")
     self.board = OpenBCIBoard(port, baud)
     
     self.bg_thread = None
     self.bg_draw_thread = None
     self.data = np.array([0]*8)
     self.should_plot = False
     self.control = np.array([0,0,0])
     self.control_s = np.array([0,0,0])
     self.control_f = np.array([0])
     self.out_sig = np.array([0])
     self.controls = np.array([[0]*4])
     self.eye_r = np.array([0])
     self.eye_l = np.array([0])
     self.current = "baseline"
     
     fnn = NetworkReader.readFrom('neural_net.xml')
     self.good_indexes = joblib.load('neural_model_features.pkl')
     # self.eye_l_temp, self.eye_r_temp = joblib.load('eye_blinks.pkl')
     self.model = fnn
     
     print("connecting to teensy...")
     if TEENSY_ENABLED:
         self.teensy = serial.Serial(TEENSY_PORT, 57600)
开发者ID:Cognitive-Technology-Group,项目名称:PyOBCI,代码行数:25,代码来源:mi_controller_ml_neural2.py


示例4: LoadBananaNeuralNetwork

def LoadBananaNeuralNetwork(networkXML):
    print "Loading Banana neural network: "+str(networkXML)
    start = timer()
    global banana
    banana = NetworkReader.readFrom(networkXML)
    end = timer()
    print "Time taken to load Banana neural network: " + str(end-start)
开发者ID:mzw23,项目名称:VegeTable,代码行数:7,代码来源:VegeTableMatchServer.py


示例5: LoadAppleNeuralNetwork

def LoadAppleNeuralNetwork(networkXML):
    print "Loading Apple neural network: "+str(networkXML)
    start = timer()
    global apple
    apple = NetworkReader.readFrom(networkXML)
    end = timer()
    print "Time taken to load Apple neural network: " + str(end-start)
开发者ID:mzw23,项目名称:VegeTable,代码行数:7,代码来源:VegeTableMatchServer.py


示例6: LoadCucumberNeuralNetwork

def LoadCucumberNeuralNetwork(networkXML):
    print "Loading Cucumber neural network: "+str(networkXML)
    start = timer()
    global cucumber
    cucumber = NetworkReader.readFrom(networkXML)
    end = timer()
    print "Time taken to load Cucumber neural network: " + str(end-start)
开发者ID:mzw23,项目名称:VegeTable,代码行数:7,代码来源:VegeTableMatchServer.py


示例7: startTrials

def startTrials(ds, maxTrials = 2, maxExperiments = 2):
	"""start and run the trials"""
	hpCount = []
	for i in range(0, maxExperiments):
		for j in range(0, maxTrials):
			enemyTestPos = runExperiments.makeTestDataset()
			net = NetworkReader.readFrom("net.xml")

			netResults = net.activate([val for pair in normalize(enemyTestPos) for val in pair])
			netIter = iter(netResults)
			allyTestPos = zip(netIter, netIter)
			#undo normalization
			allyTestPos = map(lambda p: (abs(p[0]*640), abs(p[1]*720)), allyTestPos)
			print(allyTestPos)
			runExperiments.writeTestData(allyTestPos)
			runExperiments.run()

			with open("exp_results_raw.txt", "r") as resultsFile:
				lines = resultsFile.readlines()
				if "Zerg_Zergling" in lines[1]:
					x = normalize(enemyTestPos)
					y = normalize(allyTestPos)
					x = [val for pair in x for val in pair]
					y = [val for pair in y for val in pair]
					ds.addSample(x, y)
					lineSplit = lines[1].split("Zerg_Zergling")[-1]
					hpCount.append(lineSplit.split(" ")[2])
		trainer = BackpropTrainer(net, ds)
        trainer.trainUntilConvergence()
	return hpCount
开发者ID:peixian,项目名称:Ultralisk,代码行数:30,代码来源:glaive.py


示例8: _InitNet

    def _InitNet(self):

        # -----------------------------------------------------------------------
        self._pr_line();
        print("| _InitNet(self): \n");
        start_time = time.time();
        # -----------------------------------------------------------------------
        if self._NET_NAME:
            
            # -----------------------------------------------------------------------
            self._SDS = SupervisedDataSet(900, 52); 

            if self._NET_NEW:

                print('| Bulding new NET: '+self._NET_NAME)
                self._NET = buildNetwork(self._SDS.indim, self._NET_HIDDEN, self._SDS.outdim, bias=True); #,hiddenclass=TanhLayer)
                self._SaveNET();
            else:

                print('| Reading NET from: '+self._NET_NAME)
                self._NET = NetworkReader.readFrom(self._NET_NAME)
            # -----------------------------------------------------------------------
            print('| Making AutoBAK: '+str(self._MK_AUTO_BAK))
            
            if self._MK_AUTO_BAK:
                NetworkWriter.writeToFile(self._NET, self._NET_NAME+".AUTO_BAK.xml");
            # -----------------------------------------------------------------------
            print("| Done in: "+str(time.time()-start_time)+'sec');
            # -----------------------------------------------------------------------

        else:
            
            print('| Unknown NET name: >|'+self._NET_NAME+'|<')
            exit();
开发者ID:ch3ll0v3k,项目名称:AI-Alphabet,代码行数:34,代码来源:_buildNetwork-v3-Threading.py


示例9: getBoardImage

def getBoardImage(img):
    '''
    Runs an image through processing and neural network to decode digits

    img: an openCV image object

    returns:
        pil_im: a PIL image object with the puzzle isolated, cropped and straightened
        boardString: string representing the digits and spaces of a Sudoku board (left to right, top to bottom)
    '''

    # Process image and extract digits
    pil_im, numbers, parsed, missed = process(img, False)
    if pil_im == None:
        return None, None

    net = NetworkReader.readFrom(os.path.dirname(os.path.abspath(__file__))+'/network.xml')
    boardString = ''

    for number in numbers:
        if number is None:
            boardString += ' '
        else:
            data=ClassificationDataSet(400, nb_classes=9, class_labels=['1','2','3','4','5','6','7','8','9'])
            data.appendLinked(number.ravel(),[0])
            boardString += str(net.activateOnDataset(data).argmax(axis=1)[0]+1)
    return pil_im, boardString
开发者ID:kdelaney711,项目名称:sudokusolver,代码行数:27,代码来源:imagesolver.py


示例10: trainNetwork

def trainNetwork(epochs, rate, trndata, tstdata, network=None):
    '''
    epochs: number of iterations to run on dataset
    trndata: pybrain ClassificationDataSet
    tstdat: pybrain ClassificationDataSet
    network: filename of saved pybrain network, or None
    '''
    if network is None:
        net = buildNetwork(400, 25, 25, 9, bias=True, hiddenclass=SigmoidLayer, outclass=SigmoidLayer)
    else:
        net = NetworkReader.readFrom(network)

    print "Number of training patterns: ", len(trndata)
    print "Input and output dimensions: ", trndata.indim, trndata.outdim
    print "First sample input:"
    print trndata['input'][0]
    print ""
    print "First sample target:", trndata['target'][0]
    print "First sample class:", trndata.getClass(int(trndata['class'][0]))
    print ""

    trainer = BackpropTrainer(net, dataset=trndata, learningrate=rate)
    for i in range(epochs):
        trainer.trainEpochs(1)
        trnresult = percentError(trainer.testOnClassData(), trndata['class'])
        tstresult = percentError(trainer.testOnClassData(dataset=tstdata), tstdata['class'])
        print "epoch: %4d" % trainer.totalepochs, "  train error: %5.2f%%" % trnresult, "  test error: %5.2f%%" % tstresult

    return net
开发者ID:kdelaney711,项目名称:sudokusolver,代码行数:29,代码来源:network.py


示例11: load

 def load(self, path):
     """
     This function loads the neural network.
     Args:
     :param path (String): the path where the neural network is going to be loaded from.
     """
     self.network = NetworkReader.readFrom(path)
开发者ID:dtu-02819-projects-fall2014,项目名称:Introduction-to-Data-Mining-DTU,代码行数:7,代码来源:ai.py


示例12: predict

 def predict(main_words):
     cluster_to_words = pickle.load(open('myW2VModel_claster_1000.p', 'rb'))
     if len(main_words.split()) > 7:
         row_vector_array = [0] * 1000
         for w in main_words.split():
             if w in w2v_model.vocab:
                 row_vector_array[get_cluster_number(w, cluster_to_words)] = 1
         net = NetworkReader.readFrom('trained_network_continue5.xml')
         return net.activate(row_vector_array)
开发者ID:AlexandrShestak,项目名称:nlp,代码行数:9,代码来源:PostPredictor.py


示例13: onTextEntered

 def onTextEntered(self):
     model_name = "clean_text_model"
     w2v_model = Word2Vec.load(model_name)
     new_post_text = self.entry.get(1.0, END)
     row_vector_array = []
     for w in new_post_text.split():
         if w in w2v_model.vocab:
                 row_vector_array.extend(w2v_model[w])
     net = NetworkReader.readFrom('trained_network1.xml')
     result = net.activate(row_vector_array[:100])
     print result
     self.labelVariable.set("Result : " + str(result))
开发者ID:AlexandrShestak,项目名称:nlp,代码行数:12,代码来源:gui.py


示例14: _readNetworkFromFile

    def _readNetworkFromFile(self):

        # -----------------------------------------------------------------------
        self._pr_line();
        print("| _readNetworkFromFile("+self._NET_NAME+"): \n");
        start_time = time.time();
        # -----------------------------------------------------------------------

        self._NET = NetworkReader.readFrom(self._NET_NAME);


        # -----------------------------------------------------------------------
        print("| Done in: "+str(time.time()-start_time)+'sec');
开发者ID:ch3ll0v3k,项目名称:AI-Alphabet,代码行数:13,代码来源:_asc_net-v3-Threading.py


示例15: checkPerformanceTestSet

def checkPerformanceTestSet(tstFileName,numF,numC,minVals,maxVals,nnFile,threshold):
  
  data = np.genfromtxt(tstFileName)
  tstIn = data[:,0:5]
  tstOut   = data[:,6]
  tstOut = [int(val) for val in tstOut]

  for i in range(0,len(tstIn)):
    for j in range(0,numF):
      tstIn[i,j] = (tstIn[i,j]-minVals[j])/(maxVals[j]-minVals[j])

  myNetwork = NetworkReader.readFrom(nnFile)  
  return checkPerformance(myNetwork,tstIn,tstOut,numC,threshold)    
开发者ID:abdullah2891,项目名称:NeuralNet,代码行数:13,代码来源:testNeuralNetwork.py


示例16: read

def read():
    parser = argparse.ArgumentParser(description='Face detection using Neural Networks')
    parser.add_argument('-t', '--train-faces', help='Receives a directory with files to train with', nargs='+')
    parser.add_argument('-f', '--train-non-faces', help='Receives a directory with files to train with', nargs='+')
    parser.add_argument('-p', '--test', help='Receives a list of images (testing set)', nargs='+')
    parser.add_argument('-r', '--read', help='Read the file with the already trained network object', nargs=1)
    parser.add_argument('-w', '--write', help='Write the network to the specified file (format is .xml)', nargs=1)

    args = parser.parse_args()

    # Read the Neural Network Object
    if args.read:
        net = NetworkReader.readFrom(args.read[0])
    else:
        net = buildNetwork(400, 5, 2, bias=True, outclass=SoftmaxLayer)
        # net = buildNetwork(400, 80, 16, 1, bias=True, hiddenclass=TanhLayer)

    # If there are some files to train with
    if (args.train_faces or args.train_non_faces):

        if args.train_faces:
            faces = get_files(args.train_faces[0])
        else:
            faces = []

        if args.train_non_faces:
            non_faces = get_files(args.train_non_faces[0])
        else:
            non_faces = []

        # Expected targets
        faces     = map(lambda path: (path, [1]), faces)
        non_faces = map(lambda path: (path, [0]), non_faces)

        training_files = faces + non_faces
    else:
        training_files = None

    # If there are some files to test with
    if args.test:
        testing_imgs = open_imgs(args.test)
    else:
        testing_imgs = None

    # If there is a writing file
    if args.write:
        write_file = args.write[0]
    else:
        write_file = None

    return net, training_files, testing_imgs, write_file
开发者ID:Melecio,项目名称:face-detection,代码行数:51,代码来源:neural_network.py


示例17: predict_class

        def predict_class(self,_x,_y,test_file,epochs,steps):
                print("Iniciando funcao predict_class() .............")


                traindata = self.ReadTrainFile(_x,_y)
                #testdata = self.ReadTestFile( test_file, len(_x[0]) )
                
                print ("____________________________________________________________________________")
                print ("A matrix de treino tem ", len(traindata),"linhas de dados")
                print ("Dimensoes de Input e Output : ", traindata.indim, traindata.outdim)
                print ("____________________________________________________________________________\n")
                

                print("convertendo arquivos .................")

                traindata._convertToOneOfMany( )
                #testdata._convertToOneOfMany( )

                import os.path
                if os.path.exists('rede_animal.xml'):
                    print(" Carregando a rede de treinos do arquivo rede_animal.xml *************** ")
                    fnn = NetworkReader.readFrom('rede_animal.xml')
                else:
                    print(" Criando rede de treinos no arquivo rede_animal.xml *************** ")
                    fnn = buildNetwork( traindata.indim, 5, traindata.outdim, outclass=SoftmaxLayer )

                trainer = BackpropTrainer( fnn, dataset=traindata, momentum=0.1, verbose=True, weightdecay=0.01)

                print("Treinando .............")
                
                for i in range(epochs):
                        print("Treinando epoca ", i)
                        trainer.trainEpochs( steps )
                        NetworkWriter.writeToFile(fnn, 'rede_animal.xml')
                        print(" Rede salva em rede_animal.xml (Ok) ")

                print("Lendo arquivo de teste e classificando ..........")
                print("Gerando resultados em ANIMAL_OUTPUT.CSV ..........")
                output = open('animal_output.csv', 'wb')
                i=1
                output.write("ID,Adoption,Died,Euthanasia,Return_to_owner,Transfer\n")
                for line in open(test_file, 'r'):
                        x = ast.literal_eval(line)
                        output.write( "{},{},{},{},{},{} \n".format(i,fnn.activate( x )[0],fnn.activate( x )[1],fnn.activate( x )[2],fnn.activate( x )[3],fnn.activate( x )[4]) )
                        i=i+1   
                print("Concluido")

                
开发者ID:sevenleo,项目名称:animals,代码行数:46,代码来源:generate.py


示例18: __init__

    def __init__(self, network_tuple=None, epochs=1, save='', load='',
                 scale=1000, max_error=0):

        if not network_tuple and not load:
            raise TypeError('Network tuple or load must be provided.')

        self.network = NetworkReader.readFrom(load) if load else \
            buildNetwork(*network_tuple)
        self.ds = SupervisedDataSet(inp=2, target=1)
        self.scale = scale
        self.training = Thread(target=self.train, args=(epochs, max_error))
        self.training.daemon = True
        self.done = False
        self.save = save
        self.max_error = max_error
        self.epochs = epochs
开发者ID:nihn,项目名称:speedometer,代码行数:16,代码来源:neural_network.py


示例19: __init__

    def __init__(self, datadir, insize=None, outsize=None, paramfile=None):
        self.datadir = datadir
        if insize == None:
            g = runner.Game()
            ip = self._game2input(g)
            self.insize = len(ip)
        else:
            self.insize = insize
        if outsize == None:
            self.outsize = 1
        else:
            self.outsize = outsize
        if paramfile:
            f = os.path.join(self.datadir, paramfile)
            self.nn = NetworkReader.readFrom(f)
            try:
                self.name = re.search("(.*)-bestof-(.*)", paramfile).group(1)
            except AttributeError:
                self.name = "blondie-%s" % (datetime.datetime.now())
        else:
            self.nn = FeedForwardNetwork()
            tmpname = "blondie-%s" % (datetime.datetime.now())
            self.name = re.sub("[.: ]", "-", tmpname)

            inLayer = LinearLayer(self.insize)
            hiddenLayer1 = SigmoidLayer(self.insize)
            hiddenLayer2 = SigmoidLayer(self.insize)
            outLayer = LinearLayer(self.outsize)

            self.nn.addInputModule(inLayer)
            self.nn.addModule(hiddenLayer1)
            self.nn.addModule(hiddenLayer2)
            self.nn.addOutputModule(outLayer)

            in_to_hidden1 = FullConnection(inLayer, hiddenLayer1)
            hidden1_to_hidden2 = FullConnection(hiddenLayer1, hiddenLayer2)
            hidden2_to_out = FullConnection(hiddenLayer2, outLayer)

            self.nn.addConnection(in_to_hidden1)
            self.nn.addConnection(hidden1_to_hidden2)
            self.nn.addConnection(hidden2_to_out)

            self.nn.sortModules()
开发者ID:kirubakaran,项目名称:blondie18,代码行数:43,代码来源:blondiebrain.py


示例20: validates

def validates(net_path, validation_set):
    """
    Compute the average euclidean distance activating
    the model over a validation set

    :param net_path: Path to the model
    :type net_path: str
    :param validation_set: Validation set
    :type validation_set: list[tuple(list[float], list[float])]
    :return: average euclidean distance
    :rtype: float
    """
    net = NetworkReader.readFrom(net_path)
    dist = 0
    for example in validation_set:
            res = net.activate(example[0])
            res = array(res)
            target = array(example[1])
            dist += distance.euclidean(res, target)
    return dist/len(validation_set)
开发者ID:LoreDema,项目名称:ValidPy,代码行数:20,代码来源:experimentKcross.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python networkwriter.NetworkWriter类代码示例发布时间:2022-05-25
下一篇:
Python shortcuts.buildNetwork函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap