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

Savvy Sahai

Data Science Intern, Capgemini
linkedin profile url

As a student looking to break into the field of data engineering and data science, one can get really confused as to which path to take. Very few ways to do it are Google, YouTube, etc. I was one of... Read More

Relevant Projects

MLOps Project to Build Search Relevancy Algorithm with SBERT
In this MLOps SBERT project you will learn to build and deploy an accurate and scalable search algorithm on AWS using SBERT and ANNOY to enhance search relevancy in news articles.

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.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

Stock Price Prediction Project using LSTM and RNN
Learn how to predict stock prices using RNN and LSTM models. Understand deep learning concepts and apply them to real-world financial data for accurate forecasting.

BERT Text Classification using DistilBERT and ALBERT Models
This Project Explains how to perform Text Classification using ALBERT and DistilBERT

Build a Graph Based Recommendation System in Python -Part 1
Python Recommender Systems Project - Learn to build a graph based recommendation system in eCommerce to recommend products.

Build CNN for Image Colorization using Deep Transfer Learning
Image Processing Project -Train a model for colorization to make grayscale images colorful using convolutional autoencoders.

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.

Avocado Machine Learning Project Python for Price Prediction
In this ML Project, you will use the Avocado dataset to build a machine learning model to predict the average price of avocado which is continuous in nature based on region and varieties of avocado.

CycleGAN Implementation for Image-To-Image Translation
In this GAN Deep Learning Project, you will learn how to build an image to image translation model in PyTorch with Cycle GAN.