VOOZH about

URL: https://www.geeksforgeeks.org/r-language/single-layered-neural-networks-in-r-programming/

⇱ Single Layered Neural Networks in R Programming - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Single Layered Neural Networks in R Programming

Last Updated : 10 Dec, 2025

A Single Layered Neural Network (SLNN), also called a perceptron, is the simplest form of a neural network where all inputs connect directly to the output through a single set of weights. It is used for tasks like basic pattern recognition, binary classification and simple prediction problems.

A Single Layered Neural Network has:

  • One input layer
  • One output layer
  • No hidden layers
  • Straightforward weight updates
  • Easy implementation and fast training

It works well when the data is linearly separable.

Architecture of a Single Layered Neural Network

  • Let input vector be x = (x1, x2, …, xn)
  • Let weights be w = (w1, w2, …, wn)
  • Network computes:y = f( w.x+ b) where f is the activation function.

Common Activation Functions

  • Step Function: for Perceptron
  • Sigmoid: for probability outputs
  • Linear Activation: for regression tasks

Step-by-Step Implementation of Single Layered Neural Network in R

Below is the complete step-by-step implementation from scratch

Step 1: Create Dataset

Step 2: Initialize Weights and Bias

Step 3: Activation Function (Step Function)

Step 4: Train the Network (Perceptron Learning Rule)

Step 5: Make Predictions

Output:

[1] 0
[1] 1
[1] 1
[1] 1

Limitations of Single Layered Neural Networks

  • Cannot solve non-linear problems like XOR
  • No hidden layers, limited learning ability
  • Works only for linearly separable data
  • Simple decision boundaries
Comment

Explore