Skip to content

A simple neural network to classify points generated using a sine function. Implementing backpropagation.

Notifications You must be signed in to change notification settings

jatin-47/Sine-Classifier

Repository files navigation

Sine-Classifier

A simple neural network to classify points generated using a sine function.
The model is trained using gradient descent algorithm with backpropagation for calculating gradients.
Graphics are generated using WinBGI graphics library in C++ language.

Generating Data:

Random points are generated for train and test set and are saved in training_set.txt and test_set.txt.

  • Train data:

    • Label 1 (RED) : Points on and above the sine graph.
    • Label 0 (GREEN): Points below the sine graph.
  • Test data:

    • Shown in YELLOW.

Neural Network:

Architecture :-

  • Input Layer: 2 nodes with two coordinates of a point.
  • Hidden Layer1: 20 nodes with sigmoid activation function.
  • Hidden Layer2: 20 nodes with sigmoid activation function.
  • Output Layer: 1 node with sigmoid activation function.

   

Cost function :-

Mean Squared Error (MSE)

Gradient Descent with Backpropagation :-

Some good resources:-

Results:

  • Test data:
    • Points in PINK are classified into Label 1 (RED).
    • Points in BLUE are classified into Label 0 (GREEN).

   


Regression Approach (Classification using Logistic Regression):

Apart from this neural network classification which is more general, I tried classification using regression also.
I assumed a general sine curve : y = Amplitude * sin(freq * x + Phase) + Offset
And then based on these 4 parameters, tried to fit this graph according to the points given.

Results:

  • Graph in WHITE is the fitted graph with the predicted 4 parameters.

  • Test data:

    • Points in PINK are classified into Label 1 (RED).
    • Points in BLUE are classified into Label 0 (GREEN).

   

About

A simple neural network to classify points generated using a sine function. Implementing backpropagation.

Topics

Resources

Stars

Watchers

Forks

Languages