0 votes
1 view
in AI and Deep Learning by (27k points)

For my Advanced Algorithms and Data Structures class, my professor asked us to pick any topic that interested us. He also told us to research it and to try and implement a solution in it. I chose Neural Networks because it's something that I've wanted to learn for a long time.

I've been able to implement an AND, OR, and XOR using a neural network whose neurons use a step function for the activator. After that, I tried to implement a back-propagating neural network that learns to recognize the XOR operator (using a sigmoid function as the activator). I was able to get this to work 90% of the time by using a 3-3-1 network (1 bias at the input and hidden layer, with weights initialized randomly). At other times it seems to get stuck in what I think is a local minima, but I am not sure (I've asked questions on this before and people have told me that there shouldn't be a local minima).

The 90% of the time it was working, I was consistently presenting my inputs in this order: [0, 0], [0, 1], [1, 0], [1, 0] with the expected output set to [0, 1, 1, 0]. When I present the values in the same order consistently, the network eventually learns the pattern. It doesn't matter in what order I send it in, as long as it is the same order for each epoch.

I then implemented randomization of the training set, and so this time the order of inputs is sufficiently randomized. I've noticed now that my neural network gets stuck and the errors are decreasing, but at a very small rate (which is getting smaller at each epoch). After a while, the errors start oscillating around a value (so the error stops decreasing).

I'm a novice at this topic and everything I know so far is self-taught (reading tutorials, papers, etc.). Why does the order of presentation of inputs change the behavior of my network? Is it because the change in error is consistent from one input to the next (because the ordering is consistent), which makes it easy for the network to learn?

What can I do to fix this? I'm going over my backpropagation algorithm to make sure I've implemented it right; currently, it is implemented with a learning rate and a momentum. I'm considering looking at other enhancements like an adaptive learning rate. However, the XOR network is often portrayed as a very simple network and so I'm thinking that I shouldn't need to use a sophisticated backpropagation algorithm.

1 Answer

0 votes
by (57.2k points)

The inputs didn't correspond to the outputs which ensured that the network didn't learn anything! You also have to modify your backpropagation algorithm to adjust the weights only after the error has been calculated for all nodes in the network. 

The order in which you present the observations (input vectors) comprising your training set to the network only matters in one respect that is the randomized arrangement of the observations according to the response variable is heavily preferred versus ordered arrangement.

For instance, suppose you have 150 observations comprising your training set, and for each, the response variable is one of three class labels (class I, II, or III), such that observations 1-50 are in class I, 51-100 in class II, and 101-50 in class III. What you do not want to perform is present them to the network in that order means you do not want the network to see all 50 observations in class I, then all 50 present in class II, then all 50 in class III.

What happened during training your classifier is that initially, you were presenting the four observations to your network, unordered [0, 1, 1, 0].

If the input order was [1, 1, 0, 0], or [0, 1, 1, 1], this is consistent with this well-documented empirical rule mentioned above.

On the other hand, you have so few training instances that even if the order is [1, 1, 0, 0], training over multiple epochs will mean that this ordering looks more "randomized" rather than the example mentioned above.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...