Projects Inventory

Simulation of Artificial Neural Networks Gaming Project in C++

Explanation

  1. Headers:
    • <iostream>: For input and output operations.
    • <vector>: For using the std::vector container.
    • <cmath>: For mathematical functions like exp()
      Advertisement
      .
    • <cstdlib>: For rand() and srand() functions.
    • <ctime>: For time() function to seed the random number generator.
  2. Activation Function:
    • double sigmoid(double x): Computes the sigmoid activation function.
    • double sigmoidDerivative(double x): Computes the derivative of the sigmoid function (not used in this simple example but essential for learning).
    • Advertisement
  3. NeuralNetwork Class:
    • Attributes:
      • weights: 2D vector holding the weights of the neurons.
      • biases: Vector holding the biases for each neuron.
      • outputs: Vector to store the output of each neuron.
    • Constructor:
      • Initializes weights and biases with random values.
    • Methods:
      • void forward(const vector<double>& inputs): Performs forward propagation by computing the weighted sum of inputs, adding the bias, and applying the sigmoid activation function.
      • void printOutputs() const: Prints the output of the network.
  4. Main Function:
    • Initialization:
      • Creates a NeuralNetwork object with a specified input size and output size.
      • Defines a vector of inputs.
    • Simulation:
      • Runs forward propagation with the example inputs.
      • Prints the network outputs.

Notes:

Exit mobile version