How to use connections to build a network in PyBrain

This recipe helps you use connections to build a network in PyBrain

Recipe Objective - How to use connections to build a network in PyBrain?

Connection works similarly to a layer; the only difference is that it moves data from node to node on a network.

For more related projects -

https://www.projectpro.io/projects/data-science-projects/deep-learning-projects
https://www.projectpro.io/projects/data-science-projects/neural-network-projects

Let's try to build a network using connections-

# Importing libraries
from pybrain.structure import FeedForwardNetwork
from pybrain.structure import LinearLayer, SigmoidLayer

# Building feed forward network model
feed_forward_network = FeedForwardNetwork()

# Making layer for input => 3 , hidden=> 3 and output=>1
input_layer = LinearLayer(3)
hidden_layer = SigmoidLayer(3)
output_layer = LinearLayer(1)

# Adding the layer to feedforward network
feed_forward_network.addInputModule(input_layer)
feed_forward_network.addModule(hidden_layer)
feed_forward_network.addOutputModule(output_layer)

# Making connection between input ,hidden and output
input_to_hidden = FullConnection(input_layer, hidden_layer)
hidden_to_output = FullConnection(hidden_layer, output_layer)

# Adding connection to the network
feed_forward_network.addConnection(input_to_hidden)
feed_forward_network.addConnection(hidden_to_output)
feed_forward_network.sortModules()

# Printing network
print(feed_forward_network)

Output -
FeedForwardNetwork-14
   Modules:
    [<LinearLayer 'LinearLayer-11'>, <SigmoidLayer 'SigmoidLayer-15'>, <LinearLayer 'LinearLayer-16'>]
   Connections:
    [<FullConnection 'FullConnection-12': 'LinearLayer-11' -> 'SigmoidLayer-15'>, <FullConnection 'FullConnection-13': 'SigmoidLayer-15' -> 'LinearLayer-16'>]

In this way, we can use connections to build a network in pybrain.

What Users are saying..

profile image

Ed Godalle

Director Data Analytics at EY / EY Tech
linkedin profile url

I am the Director of Data Analytics with over 10+ years of IT experience. I have a background in SQL, Python, and Big Data working with Accenture, IBM, and Infosys. I am looking to enhance my skills... Read More

Relevant Projects

Build CI/CD Pipeline for Machine Learning Projects using Jenkins
In this project, you will learn how to create a CI/CD pipeline for a search engine application using Jenkins.

Multi-Class Text Classification with Deep Learning using BERT
In this deep learning project, you will implement one of the most popular state of the art Transformer models, BERT for Multi-Class Text Classification

Build a Multi Class Image Classification Model Python using CNN
This project explains How to build a Sequential Model that can perform Multi Class Image Classification in Python using CNN

Image Segmentation using Mask R-CNN with Tensorflow
In this Deep Learning Project on Image Segmentation Python, you will learn how to implement the Mask R-CNN model for early fire detection.

Deep Learning Project for Beginners with Source Code Part 1
Learn to implement deep neural networks in Python .

Recommender System Machine Learning Project for Beginners-4
Collaborative Filtering Recommender System Project - Comparison of different model based and memory based methods to build recommendation system using collaborative filtering.

A/B Testing Approach for Comparing Performance of ML Models
The objective of this project is to compare the performance of BERT and DistilBERT models for building an efficient Question and Answering system. Using A/B testing approach, we explore the effectiveness and efficiency of both models and determine which one is better suited for Q&A tasks.

Multilabel Classification Project for Predicting Shipment Modes
Multilabel Classification Project to build a machine learning model that predicts the appropriate mode of transport for each shipment, using a transport dataset with 2000 unique products. The project explores and compares four different approaches to multilabel classification, including naive independent models, classifier chains, natively multilabel models, and multilabel to multiclass approaches.

Linear Regression Model Project in Python for Beginners Part 1
Machine Learning Linear Regression Project in Python to build a simple linear regression model and master the fundamentals of regression for beginners.

MLOps Project to Deploy Resume Parser Model on Paperspace
In this MLOps project, you will learn how to deploy a Resume Parser Streamlit Application on Paperspace Private Cloud.