Friday, September 26, 2008

Activity 20: Neural Networks

In this activity, we use neural networks as another method to classify our objects into groups depending on the values of the extracted features. Similar to activity 19, we use 2 classes: kwekkwek and pillows. However, only 2 features are used to differentiate the 2 groups for simplicity. These are the length to height ratio and the red component of color.

A neural network is a computational model of how neurons in the brain work. It is a preferred alternative to linear discriminant analysis in the pattern recognition because one does not need heuristics and recognition rules to perform classification. Instead neural networks “learn” the rules of a mapping by example. Although it may take a long time for a network to train, its recognition processing speed is faster once it has learned.

source: M. Soriano, A20 - Neural Networks.pdf
____________________________________________________________________

A code was already prepared by J. Tugaff and it only needs to be modified depending on the number and values of the input features. For our purposes, we have:

2 input features
4 training objects from each class (kwekkwek and pillows)
4 test objects from each class


We first train our neural network using the training set.

Length/Height, Red component --(kwek kwek; pillows)
0.97, 0.74
1.00, 0.77
0.96, 0.73
0.91, 0.74
0.96, 0.30
1.00, 0.30
1.02, 0.33
1.02, 0.33
____________________________________________________________________

//original code c/o Jeric Tugaff

//ensure the same starting point each time
rand('seed',0);

//network def.
//neurons per layer, including input
//2 neurons in the input layer, 2 in the hidden layer and 1 in the output layer
N = [2,2,1];

//inputs, 1st column = length/height, 2nd column = red component
//training set
x = [0.97, 0.74;
1.00, 0.77;
0.96, 0.73;
0.91, 0.74;
0.96, 0.30;
1.00, 0.30;
1.02, 0.33;
1.02, 0.33]';

//targets, 0 if kwekkwek and 1 if pillows
t = [0 0 0 0 1 1 1 1];
//learning rate is 0.1 and 0 is the threshold for the error tolerated by the network
lp = [0.1,0];

W = ann_FF_init(N);

//training cycles
T = 1000;
W = ann_FF_Std_online(x,t,N,W,lp,T);
//x is the training, t is the output, W is the initialized weights,
//N is the NN architecture, lp is the learning rate and T is the number of iterations

//full run
ann_FF_run(x,N,W)
//the network N was tested using x as the test set, and W as the weights of the connections
____________________________________________________________________

We expect that this code will output values close to (0, 0, 0, 0, 1, 1, 1, 1), meaning that the first 4 objects will be classified as members of the 'kwekkwek' class while the last 4 objects will be classified as members of the 'pillows' class. The actual results are (0.1448030, 0.1291128, 0.1506565, 0.1342528, 0.8876302, 0.8956291, 0.8738883, 0.8738883). We can now say that our neural network has "learned" the features of each class and has sorted the objects into the correct groups. We now use the test set to see whether the network can classify the other objects accurately as well.

Length/Height, Red component --(kwek kwek; pillows)
0.67, 0.77
0.81, 0.79
1.08, 0.78
1.00, 0.81
1.09, 0.35
1.12, 0.35
1.05, 0.35
0.94, 0.32

Using the training parameters, the resulting values are (0.0900170, 0.0954682, 0.1355222, 0.1071037, 0.8711712, 0.8782258, 0.8610966, 0.8642343). A 100% correct classification was achieved. Next, we try to tweak the parameters (learning rate and training cycles) to see whether the values will go closer to 0 and 1 or whether the clasification will still remain 100% correct.

learning rate = from 0.1 --> change to 1.0
training cycles = from 1000 --> change to 400
result: (0.0201587, 0.0220962, 0.0384002, 0.0265042, 0.9631881, 0.9668789, 0.9575001, 0.9582095)

The values are closer to 0 and 1 using the new training parameters and the classification is still 100% correct. Now, let us try to change the order of the test set to make sure that the 100% correct classification does not depend on the order.

Length/Height, Red component --(kwek kwek; pillows)
0.67, 0.77
1.05, 0.35
1.08, 0.78
1.09, 0.35
0.81, 0.79
1.12, 0.35
0.94, 0.32
1.00, 0.81

learning rate = 1.0
training cycles = 400
result: (0.0201587, 0.9575001, 0.0384002, 0.9631881, 0.0220962, 0.9668789, 0.9582095, 0.0265042)

The classification is still 100% correct and we have shown that the order of the objects in the input matrix is not important.
____________________________________________________________________

I give myself 10 points for this activity because of the 100% correct classification of the objects into their respective classes. Thanks to Jeric Tugaff for the ANN toolbox and the code and Mark Leo Bejemino for helping me to apply the code to my objects and extracted features.

38 comments:

如此的 said...

Since it is the early worm that gets eaten by the bird, sleep late.............................................

太可怕 said...

狗床
狗牙齒
刷牙

承合 said...

how do u do?

國男皓云 said...

辛苦了!祝你愈來愈好!........................................

楊怡均 said...

但行好事,莫問前程. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Rosalind治男Garney火吟 said...

The shortest answer is doing.......................................................

惠IdellA_Fecteau1231蘋 said...

本土辣妹貼圖站 辣妹城人網 辣妹貼圖站自拍本土 辣妹貼圖站自拍 跟辣妹做愛短片 美國辣妹短片 性感辣妹圖 辣妹好 辣妹比基尼 日本辣妹寫真集 免費辣妹 巨乳辣妹影片 辣妹裸體影片 辣妹貼影 辣妹脫衣影片 巨乳辣妹脫衣影片 巨乳辣妹裸體影片 巨乳辣妹裸體 辣妹服務 辣妹直播服務 視訊辣妹照片 辣妹有約綜藝野球 辣妹泰正點 辣妹影片網 日本辣妹裸體 天天看辣妹 神算辣妹 辣妹情貼圖 辣妹奶奶 裸體的辣妹 藝術台辣妹有約 辣妹性感 寫真辣妹 無碼辣妹 台灣藝術台的辣妹有約 辣妹色情片 清涼辣妹自拍 辣媽辣妹後 辣妹性感照片 辣妹好色情片 辣妹圖貼區 辣妹裸體寫真 辣妹自拍照 辣妹生活照片 韓國寫真辣妹 絲襪辣妹自拍 辣妹留言版 辣妹色網 裸體辣妹照片 辣妹偷拍影片 美女短片試看av電影 美女的照片 美女爆乳 網路美女的照片 票選2009美女

RexTemples20144 said...

sex女,ut,貼影,av,高潮,女優,做愛,手機成人影片,色遊戲,成人動漫,百分百貼圖區,85cc影片,成人影音,av色情影片,A片線上,a片,sex,777,三級線上看,美女的照片,視訊做愛,78論壇,打飛機,免費視訊,成人影院,辣妹視訊,視訊聊天,影片網,kiss911,a片,交友,聊天,做愛,免費影片,性交,線上成人,網路色情,聊天,美女自慰,免費a分享,免費短片,裸照,一夜情,女優,85cc成人片,美女寫真,偷拍a,情人視訊聊天室

MathewP_Thu22269 said...

Nice post ~ 3Q..............................................................

明NathanA_Schulle said...

上來打聲招呼,祝你一切平安!.............................................

韋于倫成 said...

Many a true word is spoken in jest...................................................

智宜智宜 said...

河水永遠是相同的,可是每一剎那又都是新的。......................................................

9d5h41dV2h1f2_dgd45 said...

happy to read~ thank you!........................................

紋謙PhilCrispin0 said...

傻氣的人喜歡給心 雖然每次都被笑了卻得到了別人的心..................................................

貴寶 said...

愛情是一種發明,需要不斷改良。只是,這種發明和其他發明不一樣,它沒有專利權,隨時會被人搶走。..................................................

lulu said...

Man proposes, God disposes...................................................................

陳智強 said...

you look great today..................................................

孫陽泉 said...

Pay somebody back in his own coin.....................................................................

智能智能 said...

生存乃是不斷地在內心與靈魂交戰;寫作是坐著審判自己。......................................................................

怡如怡如 said...

幸福不是一切,人還有責任。....................................................................

凱文凱文 said...

成熟,就是有能力適應生活中的模糊。.................................................................

柏強 said...

今夜星光多美好~祝你快樂~~~~..................................................................

MariaFoley0念火 said...

相逢即是有緣~~留個言問候一聲,祝您平安順利............................................................

倫惟倫惟 said...

愛情是一種發明,需要不斷改良。只是,這種發明和其他發明不一樣,它沒有專利權,隨時會被人搶走。............................................................

江淑如 said...

雖然不能常常來看,仍然祝你人氣百分百 ............................................................

黃威宇 said...

耐斯的部落格值得推蔫!............................................................

蔡靜芳蔡靜芳 said...

THX FOR SHARE!!!感激呀!............................................................

林志莊麗芬易 said...

你所貫徹的形象,你喜愛它有多少百分比,你就幸福多少百分比................................................

劉隆季劉隆季 said...

人類的聰明,並非以經驗為依歸,而是以接受經驗的行程為依歸。..................................................

凱許倫 said...

Look before you leap.................................................

翔馨陳陳翔馨陳陳 said...

良言一句三冬暖,惡語傷人六月寒。......................................................................

黃以陳美苓富 said...

面對光明,陰影就在我們身後!加油哦!............................................................

承王蓁 said...

從人生中拿走友誼,猶如從生活中移走陽光......................................................................

子張張張善 said...

與人相處不妨多用眼睛說話,多用嘴巴思考,............................................................

孫邦柔 said...

相見亦無事,不來常思君......................................................................

翊翊翊翊張瑜翊翊翊 said...

人生是故事的創造與遺忘。............................................................

1615 said...

成功多屬於那些很快做出決定,卻又不輕易變更的人。而失敗也經常屬於那些很難做出決定,卻又經常變更的人.................................................... ............

冰微 said...

加油-不論如何都期待您的新發表!