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

Python customxml.NetworkReader类代码示例

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

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



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

示例1: __init__

    def __init__(self, mat, cmap=None, pixelspervalue=20, minvalue=None, maxvalue=None, show=True, block=False):
        """ Make a colormap image of a matrix or sequence of Matrix/Connection objects

        :key mat: the matrix to be used for the colormap.
        :key cmap: the matplotlib colormap (color scale) to use ('hot', 'hot_r', 'gray', 'gray_r', 'hsv', 'prism', pylab.cm.hot, etc)
        """
        self.colormaps = []
        if isinstance(mat, basestring):
            try:
                #nn = NetworkReader(mat, newfile=False)
                mat = NetworkReader(mat, newfile=False).readFrom(mat)
            except:
                pass

        try:  # if isinstance(mat, Trainer):
            mat = mat.module
        except:
            pass

        if isinstance(mat, Network):
            # connections is a dict with key: value pairs of Layer: Connection (ParameterContainer)
            mat = [connection for connection in mat.connections.values() if connection]
        
            # connections = mat.module.connections.values()
            # mat = []
            # for conlist in connections:
            #     mat += conlist

        try:
            mat = [v for (k, v) in mat.iteritems()]
            if not any(isinstance(m, (ParameterContainer, Connection)) for m in mat):
                raise ValueError("Don't know how to display ColorMaps for a sequence of type {} containing key, values of type {}: {}".format(
                                 type(mat), *[type(m) for m in mat.iteritems().next()]))
        except AttributeError:
            pass
            # from traceback import print_exc
            # print_exc()
        if isinstance(mat, list):
            for m in mat:
                if isinstance(m, list):
                    if len(m) == 1:
                        m = m[0]
                    else:
                        raise ValueError("Don't know how to display a ColorMap for a list containing more than one matrix: {}".format([type(m) for m in mat]))
                try:
                    self.colormaps = [ColorMap(m, cmap=cmap, pixelspervalue=pixelspervalue, minvalue=minvalue, maxvalue=maxvalue) ]
                except ValueError:
                    self.colormaps = [ColorMap(m[0], cmap=cmap, pixelspervalue=pixelspervalue, minvalue=minvalue, maxvalue=maxvalue) ]
        else:
            self.colormaps = [ColorMap(mat)]
            # raise ValueError("Don't know how to display ColorMaps for a sequence of type {}".format(type(mat)))
        if show:
            self.show(block=block)
开发者ID:chenyuyou,项目名称:pybrain2,代码行数:53,代码来源:colormaps.py


示例2: __init__

 def __init__(self, name, deck_id):
     self.neural_network = NetworkReader.readFrom('network.xml')
     
     hero = get_hero(deck_id)
     self.deck_id = deck_id
     self.original_deck = get_deck_by_id(deck_id)
     super(Q_player, self).__init__(name, self.original_deck, hero)
开发者ID:lastkuku,项目名称:HearthstoneAI,代码行数:7,代码来源:q_player.py


示例3: classify

def classify(data,network_file='network_training_progress.xml'):
    """
    Takes two arguments, 'data' is a 1D array of floats ranging 0-1 representing grayscale values of an image,
    'network_file' is an xml file output from 'pybrain_playground.py', a pre-trained network. 
    Returns two floats, how much it guesses that a given input is a track or other, respectively.
    Again, classify()[0] is chances it is a track, classify()[1] is chances it is other. Ranged 0-1.
    
    Example:
        >>> im = loadImage('path/to/track.png')
        >>> print classify(im)[0]
        0.99
        >>> print classify(im)[1]
        0.01
    Here, 0.99 indicates it believes with 99% certainty that the image is a track, 
    and 0.01% certainty that it is not a track.
    
    !!!IMPORTANT!!!
    THE PROGRAM EXPECTS FILES OUTPUT FROM PREPROCESSING.PY,
    AND PREPREOCESSING.PY EXPECTS FILES THAT HAVE BEEN
    OUTPUT BY PLOTBLOBS.PY
    !!!IMPORTANT!!!
    
    """
    net = NetworkReader.readFrom(network_file)
    return net.activate(data)
开发者ID:acisneros-intern,项目名称:DECO-Scripts,代码行数:25,代码来源:neural_classifier.py


示例4: test

def test(filename, test_data):
    ann = NetworkReader.readFrom(filename)
    #file = open('results.csv', 'w', newline = ' ')
    rank_teams = {1: 'Philadelphia 76ers', 2: 'Los Angeles Lakers', 3: 'Brooklyn Nets', 4: 'Phoenix Suns', 
             5: 'Minnesota Timberwolves', 6: 'New Orleans Pelicans', 7: 'New York Knicks', 
             8: 'Sacramento Kings', 9: 'Milwaukee Bucks', 10: 'Denver Nuggets', 11: 'Orlando Magic', 
             12: 'Utah Jazz', 13: 'Washington Wizards', 14: 'Houston Rockets', 15: 'Chicago Bulls', 
             16: 'Memphis Grizzlies', 17: 'Dallas Mavericks', 18: 'Portland Trail Blazers', 
             19: 'Detroit Pistons', 20: 'Indiana Pacers', 21: 'Miami Heat',
             22: 'Charlotte Hornets', 23: 'Boston Celtics', 24: 'Atlanta Hawks', 
             25: 'Los Angeles Clippers', 26: 'Oklahoma City Thunder', 27: 'Toronto Raptors', 
             28: 'Cleveland Cavaliers', 29: 'San Antonio Spurs', 30: 'Golden State Warriors'}
    list_ = []
    with open('temp_file2.csv', 'w', newline = '') as fp:
        temp = csv.writer(fp)
        for i in range(1,31):
            for j in range(1, 31):
                if(i != j):
                    out = ann.activate([i, j, 0, 0, 0])
                    if (out > 1.00):
                        out = 99
                    else:
                        num = out * 100
                        out = int(num)
                    temp.writerow([rank_teams.get(i), rank_teams.get(j), out])
开发者ID:TeamBall,项目名称:CapstoneProject,代码行数:25,代码来源:neuralNetwork.py


示例5: main

def main():
    start_time = time.time()
    novice = ArtificialNovice()
    genius = ArtificialGenius()
    game = HangmanGame(genius, novice)

    if __debug__:
        print "------------------- EVALUATION ------------------------"
        network = NetworkReader.readFrom("../IA/network_weight_1000.xml")
        j = 0
        while j < 1:
            game.launch(False, None, network)
            j += 1

        print ("--- %s total seconds ---" % (time.time() - start_time))
    else:
        print "------------------- LEARNING ------------------------"
        network = buildNetwork(3, 4, 1, hiddenclass=SigmoidLayer)
        ds = SupervisedDataSet(3, 1)
        i = 0
        while i < 100:
            game.launch(True, ds)
            i += 1

        print " INITIATE trainer : "
        trainer = BackpropTrainer(network, ds)
        print " START trainer : "
        start_time_trainer = time.time()
        trainer.train()
        print ("---  END trainer in % seconds ---" % (time.time() - start_time_trainer))
        print " START EXPORT network : "
        NetworkWriter.writeToFile(network, "../IA/network_weight_test_learning.xml")
        print " END EXPORT network : "
开发者ID:CelyaRousseau,项目名称:NaoHangman,代码行数:33,代码来源:main.py


示例6: runSaveNet

def runSaveNet(netName):
	net =  NetworkReader.readFrom(netName)

	print '0,0,0->', net.activate([0,0,0])
	print '0,0,1->', net.activate([0,0,1])
	print '0,1,0->', net.activate([0,1,0])
	print '0,1,1->', net.activate([0,1,1])
	print '1,0,0->', net.activate([1,0,0])
	print '1,0,1->', net.activate([1,0,1])
	print '1,1,0->', net.activate([1,1,0])
	print '1,1,1->', net.activate([1,1,1])

	print "-----------------------------------------------------"

	print 'Max position of 0,0,0->', getMaxPosition(net.activate([0,0,0])) + 1
	print 'Max position of 0,0,1->', getMaxPosition(net.activate([0,0,1])) + 1
	print 'Max position of 0,1,0->', getMaxPosition(net.activate([0,1,0])) + 1
	print 'Max position of 0,1,1->', getMaxPosition(net.activate([0,1,1])) + 1
	print 'Max position of 1,0,0->', getMaxPosition(net.activate([1,0,0])) + 1
	print 'Max position of 1,0,1->', getMaxPosition(net.activate([1,0,1])) + 1
	print 'Max position of 1,1,0->', getMaxPosition(net.activate([1,1,0])) + 1
	print 'Max position of 1,1,1->', getMaxPosition(net.activate([1,1,1])) + 1

	print 
	print
开发者ID:nasgold,项目名称:rounder,代码行数:25,代码来源:testPredictingWinsNetwork.py


示例7: loadFromDir

    def loadFromDir(cls, dirPath):
        """
        Return a classifier, loaded from the given directory.
        """
        with codecs.open(os.path.join(dirPath, cls._CLASSIFIER_NAME), encoding='utf-8') as f:
            c = serializer.load(f.read())

        c.net = NetworkReader.readFrom(os.path.join(dirPath, cls._NET_NAME))
        return c
开发者ID:ForeverWintr,项目名称:ImageClassipy,代码行数:9,代码来源:classifier.py


示例8: xmlInvariance

def xmlInvariance(n, forwardpasses = 1):
    """ try writing a network to an xml file, reading it, rewrite it, reread it, and compare
    if the result looks the same (compare string representation, and forward processing
    of some random inputs) """
    # We only use this for file creation.
    tmpfile = tempfile.NamedTemporaryFile(dir='.')
    f = tmpfile.name
    tmpfile.close()

    NetworkWriter.writeToFile(n, f)
    tmpnet = NetworkReader.readFrom(f)
    NetworkWriter.writeToFile(tmpnet, f)
    endnet = NetworkReader.readFrom(f)

    # Unlink temporary file.
    os.unlink(f)

    netCompare(tmpnet, endnet, forwardpasses, True)
开发者ID:Boblogic07,项目名称:pybrain,代码行数:18,代码来源:helpers.py


示例9: main

def main():
    print "Calculating mfcc...."
    mfcc_coeff_vectors_dict = {}
    for i in range(1, 201):
        extractor = FeatureExtractor(
            '/home/venkatesh/Venki/FINAL_SEM/Project/Datasets/Happiness/HappinessAudios/' + str(i) + '.wav')
        mfcc_coeff_vectors = extractor.calculate_mfcc()
        mfcc_coeff_vectors_dict.update({str(i): (mfcc_coeff_vectors, mfcc_coeff_vectors.shape[0])})

    for i in range(201, 401):
        extractor = FeatureExtractor(
            '/home/venkatesh/Venki/FINAL_SEM/Project/Datasets/Sadness/SadnessAudios/' + str(i - 200) + '.wav')
        mfcc_coeff_vectors = extractor.calculate_mfcc()
        mfcc_coeff_vectors_dict.update({str(i): (mfcc_coeff_vectors, mfcc_coeff_vectors.shape[0])})

    audio_with_min_frames, min_frames = get_min_frames_audio(
        mfcc_coeff_vectors_dict)
    processed_mfcc_coeff = preprocess_input_vectors(
        mfcc_coeff_vectors_dict, min_frames)
    # frames = min_frames
    # print frames
    # print len(processed_mfcc_coeff['1'])
    # for each_vector in processed_mfcc_coeff['1']:
    #     print len(each_vector)
    print "mffcc found..."
    classes = ["happiness", "sadness"]

    training_data = ClassificationDataSet(
        26, target=1, nb_classes=2, class_labels=classes)
    # training_data = SupervisedDataSet(13, 1)
    try:
        network = NetworkReader.readFrom(
            'network_state_frame_level_new2_no_pp1.xml')
    except:
        for i in range(1, 51):
            mfcc_coeff_vectors = processed_mfcc_coeff[str(i)]
            for each_vector in mfcc_coeff_vectors:
                training_data.appendLinked(each_vector, [1])

        for i in range(201, 251):
            mfcc_coeff_vectors = processed_mfcc_coeff[str(i)]
            for each_vector in mfcc_coeff_vectors:
                training_data.appendLinked(each_vector, [0])

        training_data._convertToOneOfMany()
        print "prepared training data.."
        print training_data.indim, training_data.outdim
        network = buildNetwork(
            training_data.indim, 5, training_data.outdim, fast=True)
        trainer = BackpropTrainer(network, learningrate=0.01, momentum=0.99)
        print "Before training...", trainer.testOnData(training_data)
        trainer.trainOnDataset(training_data, 1000)
        print "After training...", trainer.testOnData(training_data)
        NetworkWriter.writeToFile(
            network, "network_state_frame_level_new2_no_pp.xml")
开发者ID:abhinavkashyap92,项目名称:sentitude,代码行数:55,代码来源:pybrain_frame_level_classifier.py


示例10: __init__

 def __init__(self, inpNeurons, hiddenNeurons, outNeurons):
     self.net = buildNetwork(inpNeurons, hiddenNeurons, outNeurons, hiddenclass=TanhLayer, bias=True)
     if raw_input('Recover Network?: y/n\n')=='y':
         print 'Recovering Network'
         net = NetworkReader.readFrom('Network1.xml')
     else:
         print 'New Network'
         self.net.randomize()
     print self.net
     self.ds = SupervisedDataSet(inpNeurons,outNeurons)
     self.trainer = BackpropTrainer(self.net, self.ds, learningrate = 0.01, momentum=0.99)
开发者ID:nahtonaj,项目名称:neuralnetworkdrone,代码行数:11,代码来源:imageProcessing.py


示例11: __init__

 def __init__(self, name, deck_id, neural_net):
     if (neural_net == None):
         path = os.path.join(os.path.dirname(os.getcwd()), 'network.xml')
         self.neural_network = NetworkReader.readFrom(path)
     else:
         self.neural_network = neural_net
   
     hero = get_hero(deck_id)
     self.deck_id = deck_id
     self.original_deck = get_deck_by_id(deck_id)
     super(Q_learner, self).__init__(name, self.original_deck, hero)
开发者ID:lastkuku,项目名称:HearthstoneAI,代码行数:11,代码来源:q_learner.py


示例12: weight_matrices

def weight_matrices(nn):
    """ Extract list of weight matrices from a Network, Layer (module), Trainer, Connection or other pybrain object"""

    if isinstance(nn, ndarray):
        return nn

    try:
        return weight_matrices(nn.connections)
    except:
        pass

    try:
        return weight_matrices(nn.module)
    except:
        pass

    # Network objects are ParameterContainer's too, but won't reshape into a single matrix,
    # so this must come after try nn.connections
    if isinstance(nn, (ParameterContainer, Connection)):
        return reshape(nn.params, (nn.outdim, nn.indim))

    if isinstance(nn, basestring):
        try:
            fn = nn
            nn = NetworkReader(fn, newfile=False)
            return weight_matrices(nn.readFrom(fn))
        except:
            pass
    # FIXME: what does NetworkReader output? (Module? Layer?) need to handle it's type here

    try:
        return [weight_matrices(v) for (k, v) in nn.iteritems()]
    except:
        try:
            connections = nn.module.connections.values()
            nn = []
            for conlist in connections:
                nn += conlist
            return weight_matrices(nn)
        except:
            return [weight_matrices(v) for v in nn]
开发者ID:ThunderShiviah,项目名称:pug-ann,代码行数:41,代码来源:util.py


示例13: main

def main():
    print "Calculating mfcc...."
    mfcc_coeff_vectors_dict = {}
    for i in range(1, 201):
        extractor = FeatureExtractor('/home/venkatesh/Venki/FINAL_SEM/Project/Datasets/Happiness/HappinessAudios/' + str(i) + '.wav')
        mfcc_coeff_vectors = extractor.calculate_mfcc()
        mfcc_coeff_vectors_dict.update({str(i): (mfcc_coeff_vectors, mfcc_coeff_vectors.shape[0])})

    for i in range(201, 401):
        extractor = FeatureExtractor('/home/venkatesh/Venki/FINAL_SEM/Project/Datasets/Sadness/SadnessAudios/' + str(i - 200) + '.wav')
        mfcc_coeff_vectors = extractor.calculate_mfcc()
        mfcc_coeff_vectors_dict.update({str(i): (mfcc_coeff_vectors, mfcc_coeff_vectors.shape[0])})

    audio_with_min_frames, min_frames = get_min_frames_audio(mfcc_coeff_vectors_dict)
    processed_mfcc_coeff = preprocess_input_vectors(mfcc_coeff_vectors_dict, min_frames)
    frames = min_frames
    print "mfcc found...."
    classes = ["happiness", "sadness"]
    try:
        network = NetworkReader.readFrom('network_state_new_.xml')
    except:
        # Create new network and start Training
        training_data = ClassificationDataSet(frames * 26, target=1, nb_classes=2, class_labels=classes)
        # training_data = SupervisedDataSet(frames * 39, 1)
        for i in range(1, 151):
            mfcc_coeff_vectors = processed_mfcc_coeff[str(i)]
            training_data.appendLinked(mfcc_coeff_vectors.ravel(), [1])
            # training_data.addSample(mfcc_coeff_vectors.ravel(), [1])

        for i in range(201, 351):
            mfcc_coeff_vectors = processed_mfcc_coeff[str(i)]
            training_data.appendLinked(mfcc_coeff_vectors.ravel(), [0])
            # training_data.addSample(mfcc_coeff_vectors.ravel(), [0])

        training_data._convertToOneOfMany()
        network = buildNetwork(training_data.indim, 5, training_data.outdim)
        trainer = BackpropTrainer(network, learningrate=0.01, momentum=0.99)
        print "Before training...", trainer.testOnData(training_data)
        trainer.trainOnDataset(training_data, 1000)
        print "After training...", trainer.testOnData(training_data)
        NetworkWriter.writeToFile(network, "network_state_new_.xml")

    print "*" * 30 , "Happiness Detection", "*" * 30
    for i in range(151, 201):
        output = network.activate(processed_mfcc_coeff[str(i)].ravel())
        # print output,
        # if output > 0.7:
        #     print "happiness"
        class_index = max(xrange(len(output)), key=output.__getitem__)
        class_name = classes[class_index]
        print class_name
开发者ID:abhinavkashyap92,项目名称:sentitude,代码行数:51,代码来源:pybrain_learning.py


示例14: import_network

	def import_network(self, filename):
		train_samples = self.samples
		train_labels  = self.labels
		
		np.random.seed(0)
		np.random.shuffle(train_samples)
		np.random.seed(0)
		np.random.shuffle(train_labels)
		
		self.net_shared = NetworkReader.readFrom(filename)
		self.ds_shared = SupervisedDataSet(300, 1)
		for i in range(len(train_samples)):  
			self.ds_shared.addSample(tuple(np.array(train_samples[i], dtype='float64')), (train_labels[i],))
			
		self.trainer_shared = BackpropTrainer(self.net_shared, self.ds_shared, verbose=True)
开发者ID:skrustev,项目名称:traffic-sign-recognition,代码行数:15,代码来源:neural_network.py


示例15: neural_predict

def neural_predict(filename, train_file, output):
    testtag, testdata = readfile(filename)
    net = NetworkReader.readFrom(train_file)
    i = 0
    num = 0
    output_file = open(output, 'w')
    output_file.write("test data size: " + str(len(testtag)) + '\n')
    output_type_list = []
    output_type_size = []
    output_type_right = []
    output_typt_error_detail = []
    for k in testdata:
        res = net.activate(k)
        if testtag[i] not in output_type_list:
            output_type_list.append(testtag[i])
            output_type_size.append(0)
            output_type_right.append(0)
            output_typt_error_detail.append([])
        j = output_type_list.index(testtag[i])
        output_type_size[j] += 1
        if labals[max_index(res)] == testtag[i]:
            num += 1
            output_type_right[j] += 1
        else:
            (output_typt_error_detail[j]).append(labals[max_index(res)])
        i += 1
    # for k in testdata:
    #     res = net.activate(k)
    #     if labals[max_index(res)] == testtag[i]:
    #         num += 1
    #     i += 1
    output_file.write("correct number: " + str(num) + '\n')
    output_file.write("correct rate: " + str(num / (float)(len(testtag))) + '\n')
    i = 0
    for x in output_type_list:
        output_file.write(x + "\t")
        output_file.write(str(output_type_right[i]) + '/' + str(output_type_size[i]) + ':'
                          + str(float(output_type_right[i]) / output_type_size[i])[0:5] + '\t')
        c = Counter(output_typt_error_detail[i])
        for y in c:
            output_file.write(y + ":" + str(c[y]) + '\t')
            print(y + ":" + str(c[y]))
        # print c
        i += 1
        output_file.write('\n')
    print num
    output_file.close()
开发者ID:YueDayu,项目名称:AdvancedDataStructureProj2,代码行数:47,代码来源:NN_predict.py


示例16: runNeuralNets

def runNeuralNets(savedNet):

	net =  NetworkReader.readFrom(savedNet)
	dataModel = createTheDataModel([2,5,9,15])

	totalGamesPredicted = 0
	totalGames = 0
	incorrect = 0
	correct = 0
	for input, target in dataModel:

	    i = list(input)
	    if len(i) != 228:
	    	continue


	    totalGames += 1
	    result = net.activate(i)[0]

	    if result > 0:
	    	result = 1
	    else:
	    	result = 0

	    # elif result < -3.2:
	    # 	result = 0
	    # else:
	    # 	continue

	    totalGamesPredicted += 1

	    if result == target[0]:
	    	correct += 1
	    else:
	    	incorrect += 1

	
	print 'correct: ' + str(correct) + " (" + str(100.0 * correct/totalGamesPredicted)[0:6] + "%)"
	print 'incorrect: ' + str(incorrect) + " (" + str(100.0 * incorrect/totalGamesPredicted)[0:6] + "%)"
	print 'totalGames: ', totalGames
	print 'totalGamesPredicted: ', totalGamesPredicted

	print

	return 
开发者ID:nasgold,项目名称:rounder,代码行数:45,代码来源:runSavedNetwork.py


示例17: testSaveNetwork

    def testSaveNetwork(self):
        """
        Save a network, make sure it's valid.
        """
        xor = NetworkReader.readFrom(self.storedXor)
        c = classifier.Classifier(imageSize=(2, 2), netSpec=(8, 1))
        c.net = xor

        storedPath = os.path.join(self.workspace, 'testNetDir')
        c.dump(storedPath)

        newC = classifier.Classifier.loadFromDir(storedPath)

        self.assertEqual(c, newC)

        #Make sure the net still works
        for image, expected in self.xorImages:
            self.assertEqual(c.classify(image)[0], expected)
开发者ID:ForeverWintr,项目名称:ImageClassipy,代码行数:18,代码来源:testClassifier.py


示例18: load

    def load(self, filename):
        with open(filename, 'rb') as f:
            inp = pickle.Unpickler(f)
            while True:
                try:
                    k, v = inp.load()
                except EOFError:
                    break
                if k == const.PNETWORK:
                    network_data = v
                elif k == const.PWINDOW:
                    if self.window:
                        if self.window != v:
                            print "[!] window differs"
                    else:
                        self.window = v
                elif k == const.PSIZE:
                    if self.size:
                        if self.size != v:
                            print "[!] size differs"
                    else:
                        self.size = v
                elif k == const.PRATIO:
                    if self.ratio:
                        if self.ratio != v:
                            print "[!] ratio differs"
                    else:
                        self.ratio = v
                elif k == const.PMULTIPLIER:
                    if self.multiplier:
                        if self.multiplier != v:
                            print "[!] multiplier differs"
                    else:
                        self.multiplier = v
                else:
                    FATAL("%r" % (k,))

        tmpfile = filename + '~net~'
        with open(tmpfile, 'wb') as f:
            f.write(network_data)
        self.net = NetworkReader.readFrom(tmpfile)
        os.unlink(tmpfile)
        self.net.sortModules()
开发者ID:majek,项目名称:transfer,代码行数:43,代码来源:network.py


示例19: open

    if os.path.isfile(out_file_name):
        out_file_read = open(out_file_name).read()
        if seqname in out_file_read:
            # print "Sequence already compared, %s, continue to next"%seqname
            line = testvector.readline()
            i = i + 1
            continue

    seqfeats = map(float, elements[3:-1])

    max_score = 0
    max_net = "none"
    for netfile in netfiles:

        net = NetworkReader.readFrom(args.n + netfile)
        score = net.activate(seqfeats)

        if score > float(args.m):
            print >> outall_file, "Testseq:\t", seqname, "\tNetwork:\t", netfile, "\tScore:\t", score

        if float(score) > max_score:
            max_score = float(score)
            max_net = netfile

    if max_score > float(args.m):
        print >> out_file, "Testseq:\t", seqname, "\tNetwork:\t", max_net, "\tScore:\t", max_score
    else:
        print >> out_file, "Nomatch Testseq:\t", seqname, "\tNetwork:\t", max_net, "\tScore:\t", max_score

    if i % 100 == 0:
开发者ID:visanuwan,项目名称:cmgfunc,代码行数:30,代码来源:CMGfunc_testNetworks.py


示例20: range

    error = -1
    for i in range(100):
        new_error = trainer.train()
        print "error: " + str(new_error)
        if abs(error - new_error) < 0.1: break
        error = new_error

    # save the network
    print "Saving neural network..."
    NetworkWriter.writeToFile(net, os.path.basename(dirname) + 'net')

if __name__ == '__main__':
    dirname = os.path.normpath(sys.argv[1])
    # wave_reader.extractFeatures(track)
    trainNetwork(dirname)
    net = NetworkReader.readFrom(os.path.basename(dirname) + 'net')
    
    # predict on some of the training examples
    print "Predicting on training set"
    data = numpy.genfromtxt(os.path.join(dirname, 'train09_seg.csv'), delimiter=",")
    labels = numpy.genfromtxt(os.path.join(dirname, 'train09REF.txt'), delimiter='\t')[0::10,1]
##    for i in range(200):
##        print net.activate(data[i]), labels[i]
    cdata = numpy.array([])
    for feature in data:
        freq = max(0, net.activate(feature))
        sample = wave_gen.saw(freq, 0.1, 44100)
        cdata = numpy.concatenate([cdata, sample])
    wave_gen.saveAudioBuffer('test.wav', cdata)
##    for freq in labels:
##        sample = wave_gen.saw(freq, 0.1, 44100)
开发者ID:tediris,项目名称:MusicML,代码行数:31,代码来源:trainer.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python customxml.NetworkWriter类代码示例发布时间:2022-05-25
下一篇:
Python tests.runModuleTestSuite函数代码示例发布时间: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