Examples of Neural Network (CS229)

Non-linear classification example

XOR / XNOR function

XOR and XNOR (not XOR) problem can classifify by neural network with complex function.


(source: https://www.coursera.org/learn/machine-learning)

AND function

Recall sigmoid function $g(z)$, there are some values to know:

$$g(4.6)\approx{0.99}$$
$$g(-4.6)\approx{0.01}$$

OR function


(source: https://www.coursera.org/learn/machine-learning)

According to the on-line class quiz above, we know that
$$g(x_i)=g(-10+20x_1+20x_2)\tag{1}$$

$x_1$ $x_2$ $g(x_i)$
0 0 $g(-10)\approx0$
1 0 $g(10)\approx1$
0 1 $g(10)\approx1$
1 1 $g(30)\approx1$

Observe the result in the right column of the table, it is only false at $x_1=0$ and $x_2=0$, so $g(x_i)$ here is an OR function.

General Idea

Negation (NOT)

If we need a not function, then put a large negative coefficient of $x_i,i\ne0$.

For example, if we want a (NOT $x_1$) AND (NOT $x_2$)(i.e. if and only if $x_1=x_2=0$ the result will be TRUE) function, the following function will be feasible.
$$g(x)=10-20x_1-20x_2$$