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


Python SupervisedDataSet.loadFromFile方法代码示例

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


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

示例1: testNets

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
def testNets():
    ds = SupervisedDataSet.loadFromFile('SynapsemonPie/boards')
    net20 = NetworkReader.readFrom('SynapsemonPie/synapsemon_primer20.xml') 
    net50 = NetworkReader.readFrom('SynapsemonPie/synapsemon_primer50.xml') 
    net80 = NetworkReader.readFrom('SynapsemonPie/synapsemon_primer80.xml') 
    net110 = NetworkReader.readFrom('SynapsemonPie/synapsemon_primer110.xml') 
    net140 = NetworkReader.readFrom('SynapsemonPie/synapsemon_primer140.xml') 
    trainer20 = BackpropTrainer(net20, ds)
    trainer50 = BackpropTrainer(net50, ds)
    trainer80 = BackpropTrainer(net80, ds)
    trainer110 = BackpropTrainer(net110, ds)
    trainer140 = BackpropTrainer(net140, ds)
    print trainer20.train()
    print trainer50.train()
    print trainer80.train()
    print trainer110.train()
    print trainer140.train()
开发者ID:johnny-zheng,项目名称:SynapsemonPy,代码行数:19,代码来源:primer_evaluation.py

示例2: run

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
def run(layers, show, epochs):
	# load data from storage
	print("Loading Data from storage...")
	DS = SupervisedDataSet.loadFromFile("Data/DSSuperNorm")
	TrainDS, TestDS = DS.splitWithProportion(0.7)

	for _, target in TrainDS:
		for x in range(8):
			if target[x] == 1:
				target[x] = .9
			else:
				target[x] = .1

	for _, target in TestDS:
		for x in range(8):
			if target[x] == 1:
				target[x] = .9
			else:
				target[x] = .1

	# create network with 7 inputs, 15 neurons in hidden layer and 4 in output layer
	# define that the range of inputs will be from -1 to 1 and there will be 
	print("Setting up NN...")
	net = nl.net.newff(nl.tool.minmax(TestDS['input']), layers)

	net.layers[-1].transf = nl.trans.SoftMax()


	# train the NN
	print("Training NN...")
	err = net.train(TestDS['input'], TestDS['target'], show=show, epochs=epochs, goal=0.000000000001)


	ary = net.sim(TrainDS['input'])


	# Display the miss rate for the testing data
	return missRate(ary, TrainDS['target'])
开发者ID:audioocelot,项目名称:Website,代码行数:40,代码来源:NN_Neurolab.py

示例3: getDatasetFromFile

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
def getDatasetFromFile(path = "/res/dataSet"):
    return SupervisedDataSet.loadFromFile(path)
开发者ID:DianaShatunova,项目名称:NEUCOGAR,代码行数:4,代码来源:main.py

示例4: len

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
from pybrain.datasets import SupervisedDataSet
print "Reading data set.."
DS = SupervisedDataSet.loadFromFile('dataset.csv')

#Split validation set
DStest, DStrain = DS.splitWithProportion( 0.25 )

#train nn
from sf.helpers import NeuralNet3L

print "Training network with {0} examples".format(len(DStrain))
net = NeuralNet3L(len(DStrain['input'][0]), 200, 1)
net.train(DStrain,lambda_reg=5,maxiter=40)


pvec = net.activate(DStest['input'])
err = 0
m = len(pvec)
print "Testing with {0} examples.".format(len(DStest))
for i in range(m):
    p = round(pvec[i])
    t = DStest['target'][i]
    if p != t:err+=1
    
print "Error on test set is:{0}%".format(err*100/m)
开发者ID:antonvh,项目名称:PySpamfilters,代码行数:27,代码来源:train_3L_nn.py

示例5: load3OrderDataSet

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
def load3OrderDataSet():
    ds = SupervisedDataSet.loadFromFile(root.path() + '/res/dataset3')
    return ds
开发者ID:kamilsa,项目名称:KAIProject,代码行数:5,代码来源:honn.py

示例6: buildNetwork

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
from pybrain.structure import RecurrentNetwork, FeedForwardNetwork
from pybrain.structure import LinearLayer, SigmoidLayer, TanhLayer
from pybrain.structure import FullConnection
from pybrain.datasets import SupervisedDataSet, ClassificationDataSet
from pybrain.utilities import percentError
from pybrain.tools.shortcuts import buildNetwork
from pybrain.supervised.trainers import BackpropTrainer
from pybrain.structure.modules import SoftmaxLayer, BiasUnit
from pylab import ion, ioff, figure, draw, contourf, clf, show, hold, plot
from scipy import diag, arange, meshgrid, where
from numpy.random import multivariate_normal
from numpy import array_equal
import pickle

DSSuperRaw = SupervisedDataSet.loadFromFile("Data/DSSuperRaw")
DSClassRaw = ClassificationDataSet.loadFromFile("Data/DSClassRaw")

DSSuperWhiten = SupervisedDataSet.loadFromFile("Data/DSSuperWhiten")
DSClassWhiten = ClassificationDataSet.loadFromFile("Data/DSClassWhiten")

DSSuperNorm = SupervisedDataSet.loadFromFile("Data/DSSuperNorm")
DSClassNorm = ClassificationDataSet.loadFromFile("Data/DSClassNorm")

layers = (14, 14, 8)

net = buildNetwork(*layers, hiddenclass=TanhLayer, bias=True, outputbias=True, outclass=SoftmaxLayer, recurrent=True)

TrainDS, TestDS = DSSuperNorm.splitWithProportion(0.7)

# TrainDS._convertToOneOfMany()
开发者ID:audioocelot,项目名称:Website,代码行数:32,代码来源:NN_Pybrain.py

示例7: read_data

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
 def read_data(self,fName="./data/mydata"):
     self.ds = SupervisedDataSet.loadFromFile(fName)
开发者ID:huangzhixin,项目名称:Mutifunction_Auto,代码行数:4,代码来源:network.py

示例8: loadDataSets

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
	def loadDataSets(self, filename):
		self.testDs = SupervisedDataSet.loadFromFile('test' + filename)
		self.trainDs = SupervisedDataSet.loadFromFile('train' + filename)
开发者ID:ncvc,项目名称:Sentiment,代码行数:5,代码来源:NeuralNet.py

示例9: SupervisedDataSet

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
    myfile.write(str(i)+'\n')
myfile.close()

#activate the neural networks
act = SupervisedDataSet(1,1)
act.addSample((0.2,),(0.880422606518061,))
n.activateOnDataset(act)
#create the test DataSet
x = numpy.arange(0.0, 1.0+0.01, 0.01)
s = 0.5+0.4*numpy.sin(2*numpy.pi*x)
tsts = SupervisedDataSet(1,1)
tsts.setField('input',x.reshape(len(x),1))
tsts.setField('target',s.reshape(len(s),1))

#read the train DataSet from file
trndata = SupervisedDataSet.loadFromFile(os.path.join(os.getcwd(),'trndata'))

#create the trainer

t = BackpropTrainer(n, learningrate = 0.01 ,
                    momentum = mom)
#train the neural network from the train DataSet

cterrori=1.0
print "trainer momentum:"+str(mom)
for iter in range(25):
  t.trainOnDataset(trndata, 1000)
  ctrndata = mv.calculateModuleOutput(n,trndata)
  cterr = v.MSE(ctrndata,trndata['target'])
  relerr = abs(cterr-cterrori)
  cterrori = cterr
开发者ID:Boblogic07,项目名称:pybrain,代码行数:33,代码来源:jpq2layersWriter.py

示例10: load_dataset

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
def load_dataset():
        open_filename = tkFileDialog.askopenfilename()
        global ds
        ds=SupervisedDataSet.loadFromFile(open_filename)
开发者ID:IDMIL,项目名称:PyImp,代码行数:6,代码来源:learn_gest_withdelta(d)outputs.py

示例11: load_dataset

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
 def load_dataset(self,open_filename):
     self.ds = SupervisedDataSet.loadFromFile(open_filename)
开发者ID:mghamsar,项目名称:PyImp,代码行数:4,代码来源:learn_gest_withInterface.py

示例12: isfile

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
from pybrain.datasets import SupervisedDataSet
from pybrain.tools.customxml.networkreader import NetworkReader
from pybrain.supervised.trainers import BackpropTrainer
from os.path import isfile
from util import feature_to_names, push_to_int, int_to_side
from constants import *

assert isfile(NETWORK_FILE_NAME)
assert isfile(TEST_FILE_NAME)

test_ds = SupervisedDataSet.loadFromFile(TEST_FILE_NAME)
print "Test dataset loaded"

net = NetworkReader.readFrom(NETWORK_FILE_NAME)
print "Network loaded"

trainer = BackpropTrainer(net)
trainer.testOnData(test_ds, verbose = True)

error = 0

for datum in test_ds:
    x, y = datum[0], datum[1][0]
    predict = push_to_int(net.activate(x))
    error += predict != y
    # print "Heroes: {0}, Result: {1}, Predict: {2}".format(", ".join(feature_to_names(x)), int_to_side(y), int_to_side(predict))

print "{0} errors out of {1} data".format(error, len(test_ds))
print "Error rate: {0}".format(float(error) / len(test_ds))
开发者ID:SsnL,项目名称:dotaPredict,代码行数:31,代码来源:test_nn.py

示例13: Caesar

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
    return ds

ceas = Caesar()

if  os.path.isfile('C:\\Users\\maxence\\Documents\\net.xml'): 
    print 'Loading Net from file'
    net=NetworkReader.readFrom('C:\\Users\\maxence\\Documents\\net.xml')
else:
    print 'Building Network'
    net = buildNetwork(50, 150, 50, bias=True, hiddenclass=TanhLayer)
#50 char max
#Normaliazed between -1 and 1 on ASCII 255, 0 for empty char,-1,993=1

if  os.path.isfile('C:\\Users\\maxence\\Documents\\ds.xml'):
    print 'Loading Dataset from file'
    ds = SupervisedDataSet.loadFromFile('C:\\Users\\maxence\\Documents\\ds.xml')  
else:
    print 'Building Dataset'
    ds = constructDataset()

tstdata,trndata =ds.splitWithProportion(0.1)
trainer = BackpropTrainer(net, trndata)

#print 'Untrained:'
#print [0,1], net.activate([0,1])
#print [0,0], net.activate([0,0])
#print [1,1], net.activate([1,1])
print 'Training'
trnerr, valerr = trainer.trainUntilConvergence( dataset=trndata,maxEpochs=50,verbose=True )
pl.plot(trnerr,'b',valerr,'r')    
pl.show()
开发者ID:maxence-schmitt,项目名称:NeuralNetwork,代码行数:33,代码来源:pybrainTest.py

示例14: ActivateNet

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
	#	print "Returned Data", net.activate(testdata)

def	ActivateNet (data):
	return net.activate(data)

#main program execution	

partition_size = int(raw_input("Partition size: "))

#dataset
dataset = SupervisedDataSet(partition_size*partition_size, 2)

load = raw_input("Do you want to load the dataset from file?: ")

if (load == 'y'):
	dataset = dataset.loadFromFile("dataset")

else:
	for filename in os.listdir("Images(Training)/A"):
		print filename
		image_file='Images(Training)/A/'+ filename
		colordata = ProcessImage(image_file, partition_size)
		#webbrowser.open("pixels.png")
		#raw_input()
		dataset.addSample(colordata, (1, 0))
		
	for filename in os.listdir("Images(Training)/B"):
		print filename
		image_file='Images(Training)/B/'+ filename
		colordata = ProcessImage(image_file, partition_size)
		#webbrowser.open("pixels.png")
开发者ID:ddemarco5,项目名称:Neural-Network-AI,代码行数:33,代码来源:base.py

示例15: open

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import loadFromFile [as 别名]
from pybrain.structure import RecurrentNetwork, FeedForwardNetwork
from pybrain.structure import LinearLayer, SigmoidLayer, TanhLayer
from pybrain.structure import FullConnection
from pybrain.datasets import SupervisedDataSet, ClassificationDataSet
from pybrain.utilities import percentError
from pybrain.tools.shortcuts import buildNetwork
from pybrain.supervised.trainers import BackpropTrainer
from pybrain.structure.modules import SoftmaxLayer, BiasUnit
from pylab import ion, ioff, figure, draw, contourf, clf, show, hold, plot
from scipy import diag, arange, meshgrid, where
from numpy.random import multivariate_normal
from numpy import array_equal
import pickle


DSSuperNorm = SupervisedDataSet.loadFromFile("Data/DSSuperNorm")

fileObject = open('NN.pybrain.net','r')

net = pickle.load(fileObject)

TrainDS, TestDS = DSSuperNorm.splitWithProportion(0.99)

for inpt, target in TestDS:
	sum = 0
	guess = net.activate(inpt)
	print("Hiphop\t  Jazz\t\tClassical\t\tCountry\t\tDance\t\tMetal\t\tReggae\t\tRock")
	for x in guess:
		sum += x
		print("{0:.6f}".format(x), end=' ')
	print("-> {}".format(target))
开发者ID:audioocelot,项目名称:Website,代码行数:33,代码来源:TestOurNN.py


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