user3010804
user3010804

Reputation: 1

Pybrain basic network organization questions

I've started building some networks in Pybrain and having a lot of fun. I'm not entirely thrilled with the docs so I've built small, simple nets and played with them to discern how the class structure and data flow works.

I have a few questions:

Setup:


n = FeedForwardNetwork()

inLayer = LinearLayer(1, name = 'Input node')
hiddenLayer = LinearLayer(1, name = 'Hidden node')
outLayer = LinearLayer(1, name = 'Output node')

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

1) When you execute the "addInputModule" method, are the nodes in that layer automatically restricted to one input each? Is there any way to have more than one?

2) It seems I cannot create a NN of one node with 4 inputs and 1 output....looks like I MUST use at least 2 nodes for any NN, because the weights are associated with the edge (i.e. connection) class. And if I have 4 inputs, I must have 4 nodes in the InputModule....

Do I have this right?

3) In the above code snippet, what are the default Threshold Functions for each node in each layer? How can I display what the T.F.'s are?

4) Is there any documentation that describes all the available inputs for each class method?

Thanks!

Gregg

Upvotes: 0

Views: 248

Answers (1)

alko
alko

Reputation: 48317

Your question is to broad, and is abit offtopic for this reason. Nonetheless, I'll try to address some of your issues.

  • You have to add connections between layers with n.addConnection
  • A node represents an input, so for 4 input - 1 output NN you need an input layer with 4 neurons, see below. Note that 1 output means that this is simply a yes-no classifier, as it can predict whether a sample belong to exactly one class. 4 inputs means that NN classifies samples with 4 features (i.e. vectors in 4d space)

NN with 4 inputs and 1 output:

from pybrain import structure

fnn  = structure.FeedForwardNetwork()
in_layer = LinearLayer(4, name = 'Input node')
out_layer = LinearLayer(1, name = 'Output node')

fnn.addInputModule(in_layer)
fnn.addOutputModule(out_layer)
fnn.addConnection(structure.FullConnection(in_layer, out_layer))

Upvotes: 1

Related Questions