summaryrefslogtreecommitdiff
path: root/pybrain_experiments/test.py
blob: f7b0a015bee3b420a8eed469e92ddab1670dbafb (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
35
from pybrain.structure import FeedForwardNetwork
from pybrain.structure import LinearLayer, SigmoidLayer
from pybrain.structure import FullConnection
n = FeedForwardNetwork()

inLayer = LinearLayer(2)
hiddenLayer = SigmoidLayer(3)
outLayer = LinearLayer(1)

n.addInputModule(inLayer)
n.addModule(hiddenLayer)
n.addOutputModule(outLayer)

in_to_hidden = FullConnection(inLayer, hiddenLayer)
hidden_to_out = FullConnection(hiddenLayer, outLayer)


n.addConnection(in_to_hidden)
n.addConnection(hidden_to_out)


# everything is wired together now
# this makes it usable

n.sortModules()


if __name__ == "__main__":
    #Again, this might look different on your machine -
    #the weights of the connections have already been initialized randomly.
    print n.activate([1, 2])
    #look at the hidden weights
    print in_to_hidden.params
    print hidden_to_out.params
    print n.params #weights here too