blob: f6d8ae6a894b2ea8cb6c0568fb2c726a3a313935 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
from pybrain.tools.shortcuts import buildNetwork
from pybrain.structure import SoftmaxLayer
from pybrain.datasets import SupervisedDataSet
from pybrain.supervised.trainers import BackpropTrainer
class BinaryClassifier(object):
def __init__(self):
self._default_hidden_layers = 3
pass
def _train(self, dataset):
"""
pybrain.tools.shortcuts.buildNetwork(*layers, **options)
Build arbitrarily deep networks.
layers should be a list or tuple of integers, that
indicate how many neurons the layers should have.
bias and outputbias are flags to indicate whether
the network should have the corresponding biases;
both default to True.
"""
net = buildNetwork(
dataset.params_length,
self._default_hidden_layers,
1 # a binary classifier only requires one output layer
)
ds = SupervisedDataSet(dataset)
trainer = BackpropTrainer(net, ds)
trainer.trainUntilConvergence()
net.activate(params.as_serialized)
def classify(self, dataset):
return False
|