Monday 27 August 2018

Neural Networks Simplified - 4

BASİTLEŞTİRİLMİŞ YAPAY SİNİR AĞLARI - 4
Bu eğitim metni Hinton'un iki kursunda kullanılan yapılar
için yapılmış basit örneklere dayanır.  Bu kurslar sırasında
verilen örnekler internet üzerinde yaygın şekilde bulunabilir.

Bu kısımda Hinton'un kullanmış olduğu grafik fonksiyonları
örneklerle anlatılacak.

NEURAL NETWORKS SIMPLIFIED - 4
This is a tutorial based on simple examples made for the
structures used in Hinton's two courses.  The exercises
given during these courses are widely available on the internet.

The graphics functions that Hinton has used will be studied
in this section.

Herhangi bir soru varsa beni aramakta tereddüt etmeyiniz.
Please do not hesitate to contact me if any questions.

Ali R+ SARAL
arsaral((at))yaho(o).com


GRAPHICS FUNCTIONS
*******************************************

x = -10:0.1:10;
plot (x, sin (x))
octave:3> x = -10:0.1:10; plot (x, sin (x),'+');
octave:4> x = -10:0.1:10; plot (x, sin (x),'-');
octave:5> x = -10:0.1:10; plot (x, sin (x),2)
octave:7> x = -10:0.1:10; plot (x, sin (x),'b*')
octave:8> x = -10:0.1:10; plot (x, sin (x),'ro')



scatter
x = randn (100, 1);
y = randn (100, 1);
scatter (x, y, [], sqrt(x.^2 + y.^2));


x =

   0   1   2

octave:81> y
y =

   0   1   2

octave:82> z
z =

   0   0   0
   0   1   2
   0   2   4

x = 0:2; y = x;
z = x’ * y;
contour (x, y, z, 2:3)



octave:9> x=0:4;y=x;
octave:10> z=x'*y;
octave:11> contour(x,y,z,1:5)
octave:12> x
x =

   0   1   2   3   4

octave:13> y
y =

   0   1   2   3   4

octave:14> z
z =

    0    0    0    0    0
    0    1    2    3    4
    0    2    4    6    8
    0    3    6    9   12
    0    4    8   12   16


x=linspace(-2*pi,2*pi);
y=linspace(0,4*pi);
[X,Y] = meshgrid(x,y);
Z=sin(X)+cos(Y);
figure
contour(X,Y,Z)



fplot ("cos", [0, 2*pi]);
fplot ("[cos(x), sin(x)]", [0, 2*pi]);



octave:2> tx=ty=linspace(-8, 8, 4)
tx =

  -8.0000  -2.6667   2.6667   8.0000

octave:3> [xx, yy] = meshgrid(tx, ty)
xx =

  -8.0000  -2.6667   2.6667   8.0000
  -8.0000  -2.6667   2.6667   8.0000
  -8.0000  -2.6667   2.6667   8.0000
  -8.0000  -2.6667   2.6667   8.0000

yy =

  -8.0000  -8.0000  -8.0000  -8.0000
  -2.6667  -2.6667  -2.6667  -2.6667
   2.6667   2.6667   2.6667   2.6667
   8.0000   8.0000   8.0000   8.0000



tx = ty = linspace (-8, 8, 41)’;
[xx, yy] = meshgrid (tx, ty);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
tz = sin (r) ./ r;
mesh (tx, ty, tz);




[x, y, z] = peaks (20);
scatter3 (x(:), y(:), z(:), [], z(:));



subplot (2, 1, 1);
 fplot (@sin, [-10, 10]);
subplot (2, 1, 2);
fplot (@cos, [-10, 10]);



imagesc(A);

title('Original');




imshow(to_show, [-extreme, extreme]);
       
title('hidden units of the RBM');


ADVANCED FUNCTIONS
************************************************
octave:2> a=[1,2,3;4,5;6]
error: vertical dimensions mismatch (1x3 vs 1x2)
octave:2> a=1:6
a =

   1   2   3   4   5   6

octave:3> reshape(a,2,3)
ans =

   1   3   5
   2   4   6

octave:4> reshape(a,3,2)
ans =

   1   4
   2   5
   3   6

octave:7> b=repmat(c,2)
b =

   1   2   1   2
   3   4   3   4
   1   2   1   2
   3   4   3   4

octave:8> b=repmat(c,2,3)
b =

   1   2   1   2   1   2
   3   4   3   4   3   4
   1   2   1   2   1   2
   3   4   3   4   3   4



FUNCTION CALLS
*******************************************************
[max_value, p] = max(h_of_x, [], 2);

octave:3> [max_value, p] = max(a,[],1)
max_value =

    1    2    3    4    5    6    7    8    9   10

p =

   1   1   1   1   1   1   1   1   1   1

octave:4> a=[1,2,3;4,5,6;7,9,2]
a =

   1   2   3
   4   5   6
   7   9   2

octave:5> [max_value, p] = max(a,[],1)
max_value =

   7   9   6

p =

   3   3   2

octave:6> [max_value, p] = max(a,[],2)
max_value =

   3
   6
   9

p =

   3
   3
   2



octave:28> s="test";
octave:29> function testFuncWithPARM(s)
> fprintf(s)
> end

octave:31> testFuncWithPARM("aaaaaa\n")
aaaaaa


octave:32> i = 0;
octave:33> function testFuncWithIntPARM(i)
> fprintf('i =%d',i)
> end

octave:34> testFuncWithIntPARM(333);
i =333



octave:35> function [out1, out2] = testFuncWithMultiPARM()
> out1=1
> out2=2
> end

octave:36> testFuncWithMultiPARM()
out1 =  1
out2 =  2
ans =  1



extFunc.m  external file
function [out3, out4] = testExtFunc()
out3=99
out4=100
end

octave:42> testExtFunc()
out3 =  99
out4 =  100
ans =  99