top of page
Search
Writer's pictureparth kohli

Feed Forward Neural Network

Updated: Dec 28, 2022


Introduction

A feed-forward neural network (FNN) is a type of artificial neural network in which the nodes’ connections do not form a cycle. As a result, it differs from its offspring, recurrent neural networks. Information always moves in one direction in a feed-forward network; it never goes backwards.



The feed forward neural network was the first and most basic artificial neural network to be created. The information in this network flows exclusively in one direction: forward, from the input nodes to the output nodes, passing through any hidden nodes (if any). In the network, there are no cycles or loops.


Applications of Feed Forward Neural Networks

While feed-forward neural networks have a simple architecture, its simplicity can be advantageous in certain machine learning applications. For example, one may set up a sequence of feed-forward neural networks with the goal of running them independently but with a modest intermediary for moderation. To manage and perform greater tasks, this process, like the human brain, relies on numerous individual neurons. Because the different networks complete their duties independently, the outputs can be integrated at the end to create a synthesized and coherent output.

The training samples are fed through the network, and the network’s output is compared to the real output. This error is used to gradually minimise the error by changing the weights of the neurons. Back propagation, often known as back-prop, is often used to do this. Stochastic Gradient Descent is the process of iteratively transmitting batches of data through the network and adjusting the weights to reduce the error (SGD). A parameter called the learning rate determines the amount by which the weights are modified.


Advantages of Feedforward Neural Networks

The Feed Forward Neural Network’s simple architecture gives it an edge in machine learning. With a modest intermediary to maintain moderation, a sequence of Feed forward networks can run independently.


Non-linear data can be simply handled and processed with a neural network that is otherwise difficult in perceptron and sigmoid neurons.


Depending on the data, the neural network architecture might be of several forms. A convolutional neural network (CNN) has, for example, registered Recurrent neural networks (RNNs) are highly optimized for text and voice processing, while they excel in image processing.


To handle huge datasets, neural networks require massive computing and physical capabilities, necessitating the use of graphics processing units (GPUs).


Feed forward Neural Network’s Layers


Layer of input

It contains the neurons that receive input. The data is subsequently passed on to the next tier. The input layer’s total number of neurons is equal to the number of variables in the dataset.


Hidden layer

This is the intermediate layer, which is concealed between the input and output layers. This layer has a large number of neurons that perform alterations on the inputs. They then communicate with the output layer.


Output layer

It is the last layer and is depending on the model’s construction. Additionally, the output layer is the expected feature, as you are aware of the desired outcome.


Neurons weights

Weights are used to describe the strength of a connection between neurons. The range of a weight’s value is from 0 to 1.


Model


pd.options.display.max_columns=50
df=pd.read_csv('weatherAUS.csv', encoding='utf-8')
df=df[pd.isnull(df['RainTomorrow'])==False]
df=df.1llna(df.mean())
df['RainTodayFlag']=df['RainToday'].apply(lambda x: 1 if x=='Yes' else 0) df['RainTomorrowFlag']=df['RainTomorrow'].apply(lambda x: 1 if x=='Yes' else 0)
X=df[['Humidity3pm']] y=df['RainTomorrowFlag'].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
model = Sequential(name="Model-with-One-Input")
model.add(Input(shape=(1,), name='Input-Layer'))
model.add(Dense(2, activation='softplus', name='Hidden-Layer'))
model.add(Dense(1, activation='sigmoid', name='Output-Layer'))
model.compile(optimizer='adam',loss='binary_crossentropy',metrics=['Accuracy', 'Precision', 'Recall'],loss_weights=None,weighted_metrics=None,run_eagerly=None, steps_per_execution=None}
model.fit(X_train train,batch_size=10,epochs=3verbose='auto',callbacks=None,validation_split=0.2,validation_data=(X_test, y_test),steps_per_epoch=None wvalidation_steps=None,,validation_batch_size=None,max_queue_size=10,use_multiprocessing=False)
pred_labels_tr = (model.predict(X_train) > 0.5).astype(int)
pred_labels_te = (model.predict(X_test) > 0.5).astype(int)
print('-------------------- Model Summary          ')
model.summary()
print('-------------------- Weights and Biases     ')
for layer in model.layers:
print("Layer: ", layer.name)
print(" --Kernels (Weights): ", layer.get_weights()[0])
print("")
print('---------- Evaluation on Training Data    ')
print(classi1cation_report(y_train, pred_labels_tr))
print("")
print('---------- Evaluation on Test Data          ')
print(classi1cation_report(y_test, pred_labels_te))
print("")


Conclusion

The Feedforward neural network was the first artificial neural network to be created without any loops or cycles. In series-related models, it has a significant influence and can be used instead of RNN. Its straightforward architecture lends itself to machine learning. In comparison to perceptron or sigmoid, FFNN makes processing non-linear data a breeze.

References


Author - Shashank Pandey


33 views0 comments

Recent Posts

See All

Comments


bottom of page