A network is composed of modules, and they are connected using connections. In this chapter, we will learn to −
We are going to use python interpreter to execute our code. To create a network in pybrain, we have to use buildNetwork api as shown below −
C:\pybrain\pybrain>python Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> from pybrain.tools.shortcuts import buildNetwork >>> network = buildNetwork(2, 3, 1) >>>
We have created a network using buildNetwork() and the params are 2, 3, 1 which means the network is made up of 2 inputs, 3 hidden and one single output.
Below are the details of the network, i.e., Modules and Connections −
C:\pybrain\pybrain>python Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from pybrain.tools.shortcuts import buildNetwork >>> network = buildNetwork(2,3,1) >>> print(network) FeedForwardNetwork-8 Modules: [<BiasUnit 'bias'>, <LinearLayer 'in'>, <SigmoidLayer 'hidden0'>, <LinearLay er 'out'>] Connections: [<FullConnection 'FullConnection-4': 'hidden0' -> 'out'>, <FullConnection 'F ullConnection-5': 'in' -> 'hidden0'>, <FullConnection 'FullConnection-6': 'bias' -< 'out'>, <FullConnection 'FullConnection-7': 'bias' -> 'hidden0'>] >>>
Modules consists of Layers, and Connection are made from FullConnection Objects. So each of the modules and connection are named as shown above.
You can access the module layers and connection individually by referring to their names as follows −
>>> network['bias'] <BiasUnit 'bias'> >>> network['in'] <LinearLayer 'in'>