Soft Computing Programs
Soft Computing Programs
Soft Computing Programs
5
6Write a program to implement sigmoid Activation Function
#include <stdio.h>
#include <math.h>
double sigmoid(double x) {
return 1.0 / (1.0 + exp(-x));
}
int main() {
double input, output;
// Read the input value from user
printf("Enter the input value: ");
scanf("%lf", &input);
// Compute the sigmoid activation function
output = sigmoid(input);
// Print the output value to the console
printf("Output: %lf\n", output);
return 0;
}
7. Write a program to implement Gaussian Activation Function
#include <stdio.h>
#include <math.h>
int main() {
// Test the Gaussian Activation Function
double x = 0.5;
double mu = 0.0;
double sigma = 1.0;
double output = gaussian(x, mu, sigma);
return 0;
}
8. Write a program to implement Bipolar Activation Function
#include <stdio.h>
double bipolar(double x) {
if (x >= 0) {
return 1.0;
} else {
return -1.0;
}
}
int main() {
// Test the bipolar Activation Function
double x = 0.5;
double output = bipolar(x);
return 0;
}
9. Write a program to implement binary Activation Function
#include <stdio.h>
int binary(double x) {
if (x >= 0) {
return 1;
} else {
return 0;
}
}
int main() {
// Test the binary Activation Function
double x = -0.5;
int output = binary(x);
return 0;
}
10.Write a program to implement Feed Forward Network
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NUM_INPUTS 2
#define NUM_HIDDEN 3
#define NUM_OUTPUTS 1
double sigmoid(double x) {
return 1.0 / (1.0 + exp(-x));
}
int main() {
// Initialize the input values
double input[NUM_INPUTS] = {0.05, 0.10};