How to build a Feed Forward Network using PyBrain

This recipe helps you build a Feed Forward Network using PyBrain

Recipe Objective - How to build a Feed-Forward Network using PyBrain?

Feed-forward Network is a neural network in which information moves between nodes and never goes back. The feed-forward network is the first and most straightforward among the networks available in the artificial neural network. Information is transmitted from the input nodes together with the hidden nodes and then to the output node.

For more related projects -

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

Let's try to build a feed-forward network -

# Example 1: without 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)

# Printing network
print(feed_forward_network)

Output -
FeedForwardNetwork-7
   Modules:
    []
   Connections:
    []

# Example 2: with 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 build a feed-forward network in pybrain.

What Users are saying..

profile image

Jingwei Li

Graduate Research assistance at Stony Brook University
linkedin profile url

ProjectPro is an awesome platform that helps me learn much hands-on industrial experience with a step-by-step walkthrough of projects. There are two primary paths to learn: Data Science and Big Data.... Read More

Relevant Projects

Deploy Transformer BART Model for Text summarization on GCP
Learn to Deploy a Machine Learning Model for the Abstractive Text Summarization on Google Cloud Platform (GCP)

Customer Market Basket Analysis using Apriori and Fpgrowth algorithms
In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.

NLP Project to Build a Resume Parser in Python using Spacy
Use the popular Spacy NLP python library for OCR and text classification to build a Resume Parser in Python.

Personalized Medicine: Redefining Cancer Treatment
In this Personalized Medicine Machine Learning Project you will learn to classify genetic mutations on the basis of medical literature into 9 classes.

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.

Build an End-to-End AWS SageMaker Classification Model
MLOps on AWS SageMaker -Learn to Build an End-to-End Classification Model on SageMaker to predict a patient’s cause of death.

Build an optimal End-to-End MLOps Pipeline and Deploy on GCP
Learn how to build and deploy an end-to-end optimal MLOps Pipeline for Loan Eligibility Prediction Model in Python on GCP

Deep Learning Project for Time Series Forecasting in Python
Deep Learning for Time Series Forecasting in Python -A Hands-On Approach to Build Deep Learning Models (MLP, CNN, LSTM, and a Hybrid Model CNN-LSTM) on Time Series Data.

Time Series Analysis with Facebook Prophet Python and Cesium
Time Series Analysis Project - Use the Facebook Prophet and Cesium Open Source Library for Time Series Forecasting in Python

MLOps Project for a Mask R-CNN on GCP using uWSGI Flask
MLOps on GCP - Solved end-to-end MLOps Project to deploy a Mask RCNN Model for Image Segmentation as a Web Application using uWSGI Flask, Docker, and TensorFlow.