Suppose I have been given the following diagram

enter image description here

I need to design a neural network to separate the points or classes. How can I do that?


From the diagram you have given, it's quite clear that you have to design a supervised network. Also, it's clear that you are dealing with a problem that's not linearly separable i.e. you can't separate two classes using a single line. Particularly, it will require three lines to separate these two classes.

From the above observations, what you can do is:

  1. Make training data sets of form [(x,y), o] where (x,y) are the co-ordinates on the plot and o is the class that point belongs to.

    Note: You can actually divide your data set into training data and test data. Just, extract the data, randomly shuffle it and take first 80% of data to train and rest 20% of data to test.

  2. Design a 2-2-2-1 neural network with bias units and some random initial weight values. This is because we will require minimum three lines to separate two classes, so 2 hidden layers (each consisting of 2 nodes and bias nodes) and 1 output layer (with bias node). The first layer is input layer with 2 nodes (no bias) as we have x-coordinate and y-coordinate.

  3. Train your training data using this network using the Error Back Propagation algorithm i.e. update the weights between the layers and the bias weights too. Run the EBP algorithm for 100-2000 epochs.

  4. Then, use the test data to see, if you get the desired output.

Note: I am NOT quite sure how to obtain the coordinates from the diagram. You can either manually note all points or research for some methods to get those points automatically from the image (some image processing algorithms).

Edit: I found a good video which explains neural networks. In the video, there is non-linear data like the one in your image which is separable using multiple lines and the network is designed to try to find curves such that data can be separated and the output resembles to that when used straight lines.

| improve this answer | |
  • $\begingroup$ can u plz supply me any study material regarding this? $\endgroup$ – user3642 Dec 31 '16 at 13:57
  • $\begingroup$ You can see some video lectures of Andrew Ng's lectures (Week 4 and 5). Also, I learnt from this book and this book. Hope this helps! :-) $\endgroup$ – kiner_shah Dec 31 '16 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy