本文整理汇总了Python中pybrain.datasets.ClassificationDataSet.getClass方法的典型用法代码示例。如果您正苦于以下问题:Python ClassificationDataSet.getClass方法的具体用法?Python ClassificationDataSet.getClass怎么用?Python ClassificationDataSet.getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.datasets.ClassificationDataSet
的用法示例。
在下文中一共展示了ClassificationDataSet.getClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import getClass [as 别名]
#Target dimension is supposed to be 1
#The targets are class labels starting from zero
for i in range(N):
alldata.appendLinked(Xdf.ix[i,:],Ydf['default_Yes'].ix[i,:])
#generate training and testing data sets
tstdata, trndata = alldata.splitWithProportion(0.10)
#classes are encoded into one output unit per class, that takes on a certain value if the class is present
trndata._convertToOneOfMany( )
tstdata._convertToOneOfMany( )
len(tstdata), len(trndata)
#calculate statistics and generate histograms
alldata.calculateStatistics()
print alldata.classHist
print alldata.nClasses
print alldata.getClass(1)
#########################################################################################
#########################################################################################
#########################################################################################
#########################################################################################
#construct the network
from pybrain.structure import FeedForwardNetwork
net=FeedForwardNetwork()
#constructing the input, hidden and output layers
from pybrain.structure import LinearLayer, SigmoidLayer
inLayer = LinearLayer(3,name="input_nodes")
hiddenLayer1 = SigmoidLayer(3,name="hidden_nodes1")
hiddenLayer2 = SigmoidLayer(3,name="hidden_nodes1")
outLayer = LinearLayer(2,name="output_node")
示例2: range
# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import getClass [as 别名]
ds_training.appendLinked(image_vector, [category])
category+=1
category = 0
for shape in shapes:
for i in range(8):
image = imread('C:/Users/alexis.matelin/Documents/Neural Networks/Visual classification/shapes/testing/'+shape+str(i+1)+'.png', as_grey=True, plugin=None, flatten=None)
image_vector = image.flatten()
ds_testing.appendLinked(image_vector, [category])
ds_training.calculateStatistics()
ds_training.getClass(0)
print(ds_training.getField('target'))
ds_training._convertToOneOfMany(bounds=[0, 1])
ds_testing._convertToOneOfMany(bounds=[0, 1])
print(ds_training.getField('target'))
net = buildNetwork(1024,12, 12, 3, hiddenclass = TanhLayer, outclass=SoftmaxLayer)
trainer = BackpropTrainer(net, dataset=ds_training, verbose=True, learningrate=0.01)
trainer.trainUntilConvergence()
out = net.activateOnDataset(ds_testing)