0% found this document useful (0 votes)
15 views4 pages

Perceptron Assignment

The document outlines an assignment to implement a perceptron model that computes net input and applies Binary and Bipolar Sigmoid activation functions. Users input three values, their corresponding weights, and a bias value, which the program uses to calculate the net input and the outputs of the activation functions. The document includes an algorithm and Java code for the implementation, along with sample input and output for clarity.

Uploaded by

Aishu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Perceptron Assignment

The document outlines an assignment to implement a perceptron model that computes net input and applies Binary and Bipolar Sigmoid activation functions. Users input three values, their corresponding weights, and a bias value, which the program uses to calculate the net input and the outputs of the activation functions. The document includes an algorithm and Java code for the implementation, along with sample input and output for clarity.

Uploaded by

Aishu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment: Perceptron Model

Implementation
Problem Statement
Title:
Implementation of a Perceptron Model for Computing Net Input and Applying Binary &
Bipolar Sigmoid Activation Functions.

Objective:
To develop a perceptron-based program where the user provides three input values,
corresponding weights, and a bias value. The program computes the net input using the
weighted sum formula and applies both Binary Sigmoid and Bipolar Sigmoid activation
functions on the computed net input.

Problem Description:
A perceptron is a fundamental unit of artificial neural networks capable of performing
classification based on given inputs, weights, and bias. In this assignment, the user should
enter three input values (x1, x2, x3), their corresponding weights (w1, w2, w3), and a bias
value (within a specified range of 0.2 to 0.3). The program should calculate the weighted
summation of inputs and weights with the bias added. The resultant net input is then
passed through both a Binary Sigmoid Activation Function and a Bipolar Sigmoid Activation
Function, and the respective outputs are displayed.

Algorithm
1. Start
2. Read three input values: x1, x2, x3
3. Read three weight values: w1, w2, w3
4. Input the bias value and validate if it lies within 0.2 and 0.3
5. Compute net input using the formula:
Net Input = (x1 × w1) + (x2 × w2) + (x3 × w3) + bias
6. Apply Binary Sigmoid activation:
f(net) = 1 / (1 + e^(-net))
7. Apply Bipolar Sigmoid activation:
f(net) = (2 / (1 + e^(-net))) - 1
8. Display the computed net input, Binary Sigmoid output, and Bipolar Sigmoid output
9. End
Program Code (Java)
import java.util.Scanner;

public class PerceptronActivation {

public static double binarySigmoid(double netInput) {


return 1 / (1 + Math.exp(-netInput));
}

public static double bipolarSigmoid(double netInput) {


return (2 / (1 + Math.exp(-netInput))) - 1;
}

public static void main(String[] args) {


Scanner sc = new Scanner(System.in);
double[] x = new double[3];
double[] w = new double[3];
double bias;

System.out.println("Enter input values (x1, x2, x3):");


for (int i = 0; i < 3; i++) {
System.out.print("x" + (i + 1) + " = ");
x[i] = sc.nextDouble();
}

System.out.println("\nEnter weight values (w1, w2, w3):");


for (int i = 0; i < 3; i++) {
System.out.print("w" + (i + 1) + " = ");
w[i] = sc.nextDouble();
}

do {
System.out.print("\nEnter bias value (between 0.2 and 0.3): ");
bias = sc.nextDouble();
if (bias < 0.2 || bias > 0.3) {
System.out.println("Invalid bias value! Please enter a value between 0.2 and 0.3.");
}
} while (bias < 0.2 || bias > 0.3);

double netInput = 0;
for (int i = 0; i < 3; i++) {
netInput += x[i] * w[i];
}
netInput += bias;

double binaryOutput = binarySigmoid(netInput);


double bipolarOutput = bipolarSigmoid(netInput);

System.out.println("\nNet Input (Σ xi*wi + bias) = " + netInput);


System.out.println("Binary Sigmoid Output = " + binaryOutput);
System.out.println("Bipolar Sigmoid Output = " + bipolarOutput);

sc.close();
}
}

Sample Input and Output


Sample Input:
Enter input values (x1, x2, x3):
x1 = 0.5
x2 = 0.8
x3 = 0.3

Enter weight values (w1, w2, w3):


w1 = 0.7
w2 = 0.6
w3 = 0.9

Enter bias value (between 0.2 and 0.3): 0.25

Sample Output:
Net Input (Σ xi*wi + bias) = 1.375
Binary Sigmoid Output = 0.798
Bipolar Sigmoid Output = 0.596

References
1. S. N. Sivanandam, S. N. Deepa, Principles of Soft Computing, Wiley India Pvt. Ltd.
2. Satish Kumar, Neural Networks: A Classroom Approach, McGraw Hill Education.
3. GeeksforGeeks — Perceptron Model (https://www.geeksforgeeks.org/perceptron-
model/)
4. JavaTpoint — Activation Functions in Neural Networks
(https://www.javatpoint.com/activation-functions-in-neural-network)
5. J. Schmidhuber, Deep Learning in Neural Networks: An Overview, Neural Networks
(Elsevier), 2015.
6. Java SE API Documentation: https://docs.oracle.com/en/java/javase/

You might also like