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
Monday, 27 August 2018
Friday, 24 August 2018
Neural Networks Simplified - 3
BASİTLEŞTİRİLMİŞ YAPAY SİNİR AĞLARI - 3
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ım ile hazır fonksiyonlar bitmiş oluyor. Bundan sonraki kısımlar
kullanıcı tarafından tanımlanan fonksiyonları ele alacak.
Daha sonra ise tek tek Hinton'un örnekleri basite indirgenerek
incelenecek.
NEURAL NETWORKS SIMPLIFIED - 3
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.
Builtin functions is ending with this section. The next section will
study the user defined functions. After that Hinton's examples will
be studied with a very simplifying approach.
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
BASIC BUILTIN FUNCTIONS
*******************************************
octave:11> any([1,0,0])
ans = 1
octave:15> eye(2,4)
ans =
Diagonal Matrix
1 0 0 0
0 1 0 0
octave:12> any (eye (2, 4))
ans =
1 1 0 0
octave:13> ~any([1,0,0])
ans = 0
octave:14> ~any (eye (2, 4))
ans =
0 0 1 1
octave:2> isnan ([13, Inf, NA, NaN])
ans =
0 0 1 1
octave:3> isinf ([13, Inf, NA, NaN])
ans =
0 1 0 0
octave:6> eval ('error ("This is a bad example");', 'printf ("This error occurred:\n%s\n", lasterr ());');
This error occurred:
This is a bad example
octave:7> eval('error ("HATAAAAAAAAAAAA");')
error: HATAAAAAAAAAAAA
octave:7> eval('error ("ERRORRRRRRRRRRRRRRR");','fprintf("HATAAAAAAA");')
HATAAAAAAA
octave:11> any([1,0,0])
ans = 1
octave:15> eye(2,4)
ans =
Diagonal Matrix
1 0 0 0
0 1 0 0
octave:12> any (eye (2, 4))
ans =
1 1 0 0
octave:13> ~any([1,0,0])
ans = 0
octave:14> ~any (eye (2, 4))
ans =
0 0 1 1
ctave:19> resets dev environment -->clc;clear;close all
octave:19> checks environment values
octave:19> if ~exist('example_width', 'var') || isempty(example_width)
> end
octave:11> a=1:10
a =
1 2 3 4 5 6 7 8 9 10
octave:12> avg(a)
ans = 5.5000
octave:13> sum(a)
ans = 55
octave:14> avg(a) == sum(a)/10
ans = 1
octave:15> sum(a)./10
ans = 5.5000
INPUT OUTPUT FUNCTIONS
*********************************************
octave:16> pause
octave:17> fprintf("Press any key to continue");pause;
Press any key to continue
octave:18> % this is a line comment
octave:18> a=1; %This is a line comment
octave:19> %{
> This is a block comment
> 5}
> %}
fprintf('%s is a name, %d is a number\n',"Ali",58);
Ali is a name, 58 is a number
octave:22> a
a = 1
octave:23> a=1:5
a =
1 2 3 4 5
octave:24> b=6:10
b =
6 7 8 9 10
octave:25> disp([a b]);
1 2 3 4 5 6 7 8 9 10
octave:26> a=1:20
a =
Columns 1 through 15:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
octave:27> a=[a; a]
a =
Columns 1 through 15:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Columns 16 through 20:
16 17 18 19 20
16 17 18 19 20
octave:30> a=[a; a]
octave:30> a=[a; a]
'less' is not recognized as an internal or external command,
operable program or batch file.
octave:31> Above message is not valid for the diary recording
octave:31> more off
octave:32> a
a =
Columns 1 through 15:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Columns 16 through 20:
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
octave:33> diary off
FILE I/O
*******************************************
octave:22> S=load("dataset1.mat");
octave:23> fieldnames(S)
ans =
{
[1,1] = neg_examples_nobias
[2,1] = pos_examples_nobias
[3,1] = w_init
[4,1] = w_gen_feas
}
size(S.neg_examples_nobias)
size(S.pos_examples_nobias)
load("dataset1.mat");
size(neg_examples_nobias)
size(pos_examples_nobias)
data = csvread('ex1data2.txt');
% Load File
fid = fopen(filename);
if fid
file_contents = fscanf(fid, '%c', inf);
fclose(fid);
else
file_contents = '';
fprintf('Unable to open %s\n', filename);
end
movieList = cell(n, 1);
for i = 1:n
% Read line
line = fgets(fid);
% Word Index (can ignore since it will be = i)
[idx, movieName] = strtok(line, ' ');
% Actual Word
movieList{i} = strtrim(movieName);
end
fclose(fid);
STRING FUNCTIONS
**********************************************************
octave:4> strtok("aaa bbbb",' ')
ans = aaa
octave:5> strtrim(" aaa bbb ")
ans = aaa bbb
octave:6> length("12345")
ans = 5
octave:7> strcmp("aaa","aaa")
ans = 1
octave:9> strfind("dfbsdfbadddd","a")
ans = 8
octave:16> email_contents ="[ARS]"
email_contents = [ARS]
octave:17> email_contents = regexprep(email_contents, '<[^<>]+>', ' ');
octave:18> email_contents
email_contents = [ARS]
octave:19> diary off
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ım ile hazır fonksiyonlar bitmiş oluyor. Bundan sonraki kısımlar
kullanıcı tarafından tanımlanan fonksiyonları ele alacak.
Daha sonra ise tek tek Hinton'un örnekleri basite indirgenerek
incelenecek.
NEURAL NETWORKS SIMPLIFIED - 3
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.
Builtin functions is ending with this section. The next section will
study the user defined functions. After that Hinton's examples will
be studied with a very simplifying approach.
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
BASIC BUILTIN FUNCTIONS
*******************************************
octave:11> any([1,0,0])
ans = 1
octave:15> eye(2,4)
ans =
Diagonal Matrix
1 0 0 0
0 1 0 0
octave:12> any (eye (2, 4))
ans =
1 1 0 0
octave:13> ~any([1,0,0])
ans = 0
octave:14> ~any (eye (2, 4))
ans =
0 0 1 1
octave:2> isnan ([13, Inf, NA, NaN])
ans =
0 0 1 1
octave:3> isinf ([13, Inf, NA, NaN])
ans =
0 1 0 0
octave:6> eval ('error ("This is a bad example");', 'printf ("This error occurred:\n%s\n", lasterr ());');
This error occurred:
This is a bad example
octave:7> eval('error ("HATAAAAAAAAAAAA");')
error: HATAAAAAAAAAAAA
octave:7> eval('error ("ERRORRRRRRRRRRRRRRR");','fprintf("HATAAAAAAA");')
HATAAAAAAA
octave:11> any([1,0,0])
ans = 1
octave:15> eye(2,4)
ans =
Diagonal Matrix
1 0 0 0
0 1 0 0
octave:12> any (eye (2, 4))
ans =
1 1 0 0
octave:13> ~any([1,0,0])
ans = 0
octave:14> ~any (eye (2, 4))
ans =
0 0 1 1
ctave:19> resets dev environment -->clc;clear;close all
octave:19> checks environment values
octave:19> if ~exist('example_width', 'var') || isempty(example_width)
> end
octave:11> a=1:10
a =
1 2 3 4 5 6 7 8 9 10
octave:12> avg(a)
ans = 5.5000
octave:13> sum(a)
ans = 55
octave:14> avg(a) == sum(a)/10
ans = 1
octave:15> sum(a)./10
ans = 5.5000
INPUT OUTPUT FUNCTIONS
*********************************************
octave:16> pause
octave:17> fprintf("Press any key to continue");pause;
Press any key to continue
octave:18> % this is a line comment
octave:18> a=1; %This is a line comment
octave:19> %{
> This is a block comment
> 5}
> %}
fprintf('%s is a name, %d is a number\n',"Ali",58);
Ali is a name, 58 is a number
octave:22> a
a = 1
octave:23> a=1:5
a =
1 2 3 4 5
octave:24> b=6:10
b =
6 7 8 9 10
octave:25> disp([a b]);
1 2 3 4 5 6 7 8 9 10
octave:26> a=1:20
a =
Columns 1 through 15:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
octave:27> a=[a; a]
a =
Columns 1 through 15:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Columns 16 through 20:
16 17 18 19 20
16 17 18 19 20
octave:30> a=[a; a]
octave:30> a=[a; a]
'less' is not recognized as an internal or external command,
operable program or batch file.
octave:31> Above message is not valid for the diary recording
octave:31> more off
octave:32> a
a =
Columns 1 through 15:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Columns 16 through 20:
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
16 17 18 19 20
octave:33> diary off
FILE I/O
*******************************************
octave:22> S=load("dataset1.mat");
octave:23> fieldnames(S)
ans =
{
[1,1] = neg_examples_nobias
[2,1] = pos_examples_nobias
[3,1] = w_init
[4,1] = w_gen_feas
}
size(S.neg_examples_nobias)
size(S.pos_examples_nobias)
load("dataset1.mat");
size(neg_examples_nobias)
size(pos_examples_nobias)
data = csvread('ex1data2.txt');
% Load File
fid = fopen(filename);
if fid
file_contents = fscanf(fid, '%c', inf);
fclose(fid);
else
file_contents = '';
fprintf('Unable to open %s\n', filename);
end
movieList = cell(n, 1);
for i = 1:n
% Read line
line = fgets(fid);
% Word Index (can ignore since it will be = i)
[idx, movieName] = strtok(line, ' ');
% Actual Word
movieList{i} = strtrim(movieName);
end
fclose(fid);
STRING FUNCTIONS
**********************************************************
octave:4> strtok("aaa bbbb",' ')
ans = aaa
octave:5> strtrim(" aaa bbb ")
ans = aaa bbb
octave:6> length("12345")
ans = 5
octave:7> strcmp("aaa","aaa")
ans = 1
octave:9> strfind("dfbsdfbadddd","a")
ans = 8
octave:16> email_contents ="[ARS]
email_contents = [ARS]
octave:17> email_contents = regexprep(email_contents, '<[^<>]+>', ' ');
octave:18> email_contents
email_contents = [ARS]
octave:19> diary off
Thursday, 23 August 2018
NEURAL NETWORKS SIMPLIFIED - 2
BASİTLEŞTİRİLMİŞ YAPAY SİNİR AĞLARI - 2
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ım daha ileri hazır fonksiyonları içerir.
NEURAL NETWORKS SIMPLIFIED - 2
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.
This section includes more advanced built-in functions.
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
MATRIX UTILITY FUNCTIONS
*******************************************************
octave:2> a=[1,2,3;4,5,6]
a =
1 2 3
4 5 6
octave:3> log(a)
ans =
0.00000 0.69315 1.09861
1.38629 1.60944 1.79176
octave:4> a=[-1,-2,3;4,-5,-6]
a =
-1 -2 3
4 -5 -6
octave:5> abs(a)
ans =
1 2 3
4 5 6
octave:6> exp(a)
ans =
3.6788e-001 1.3534e-001 2.0086e+001
5.4598e+001 6.7379e-003 2.4788e-003
octave:7> sum(a)
ans =
3 -7 -3
octave:8> a
a =
-1 -2 3
4 -5 -6
octave:9> sumsq(a)
ans =
17 29 45
octave:10> a=[4,9]
a =
4 9
octave:11> sqrt(a)
ans =
2 3
octave:12> mod(a,2)
ans =
0 1
octave:13> mod(3,2)
ans = 1
octave:14> floor ([-2.7, 2.7])
ans =
-3 2
octave:15> floor(3.4)
ans = 3
octave:16> ceil(3.4)
ans = 4
octave:17> ceil([-2.7,2.7])
ans =
-2 3
octave:18> realmax()
ans = 1.7977e+308
octave:19> a=[1,2,3;4,5,6;7,8,9]
a =
1 2 3
4 5 6
7 8 9
octave:20> bsxfun(@minus, a,2)
ans =
-1 0 1
2 3 4
5 6 7
octave:21> a=[3,1,5;3,4,2;7,3,5]
a =
3 1 5
3 4 2
7 3 5
octave:22> sort(a)
ans =
3 1 2
3 3 5
7 4 5
octave:23> a
a =
3 1 5
3 4 2
7 3 5
octave:24> sort ([1, 2; 2, 3; 3, 1])
ans =
1 1
2 2
3 3
octave:25> [s, i] = sort ([1, 2; 2, 3; 3, 1])
s =
1 1
2 2
3 3
i =
1 3
2 1
3 2
octave:26> [s, i] = sort ([1, 2; 2, 3; 3, 1], 'descend');
octave:27> s
s =
3 3
2 2
1 1
octave:28> i
i =
3 2
2 1
1 3
octave:29> a
a =
3 1 5
3 4 2
7 3 5
octave:30> mean(a)
ans =
4.3333 2.6667 4.0000
octave:31> find(a==2)
ans = 8
octave:32> a(8)
ans = 2
octave:33> a=[1,1;1,1]
a =
1 1
1 1
octave:34> inv(a)
warning: inverse: matrix singular to machine precision, rcond = 0
ans =
Inf Inf
Inf Inf
octave:35> pinv(a)
ans =
0.25000 0.25000
0.25000 0.25000
octave:36> a=[1,2,3;4,5,6]
a =
1 2 3
4 5 6
octave:37> pinv(a)
ans =
-0.94444 0.44444
-0.11111 0.11111
0.72222 -0.22222
octave:38> a=[1,2,3;4,5,6;7,8,9]
a =
1 2 3
4 5 6
7 8 9
octave:39> X=[ones(3,1) a]
X =
1 1 2 3
1 4 5 6
1 7 8 9
octave:40> b=[1;2;3]
b =
1
2
3
octave:41> a(2,:) = b
a =
1 2 3
1 2 3
7 8 9
octave:42> a
a =
1 2 3
1 2 3
7 8 9
octave:43> a(2,:) = b'
a =
1 2 3
1 2 3
7 8 9
octave:44> Y=[a(:) ; b(:)]
Y =
1
1
7
2
2
8
3
3
9
1
2
3
octave:45> find(a>3)
ans =
3
6
9
octave:46> a
a =
1 2 3
1 2 3
7 8 9
octave:47> ndx=find(a>3)
ndx =
3
6
9
octave:48> for i=1:length(ndx)
> a(ndx(i)) = 1;
> end
octave:49> a
a =
1 2 3
1 2 3
1 1 1
octave:50>
octave:50> a=[1.2,3.4,5.0]
a =
1.2000 3.4000 5.0000
octave:51> round(a)
ans =
1 3 5
octave:52> randperm(3,4)
ans =
2 3 1
1 2 3
1 3 2
2 1 3
octave:53> randperm(3)
ans =
2 1 3
octave:54> a=cell(2,4)
a =
{
[1,1] = [](0x0)
[2,1] = [](0x0)
[1,2] = [](0x0)
[2,2] = [](0x0)
[1,3] = [](0x0)
[2,3] = [](0x0)
[1,4] = [](0x0)
[2,4] = [](0x0)
}
octave:55> a(1,1)=5
a =
{
[1,1] = 5
[2,1] = [](0x0)
[1,2] = [](0x0)
[2,2] = [](0x0)
[1,3] = [](0x0)
[2,3] = [](0x0)
[1,4] = [](0x0)
[2,4] = [](0x0)
}
octave:59> a=["a","b"]
a = ab
octave:60> a(1,1)
ans = a
octave:61> a(1,2)
ans = b
octave:62> a
a = ab
octave:63> a=cell(2)
a =
{
[1,1] = [](0x0)
[2,1] = [](0x0)
[1,2] = [](0x0)
[2,2] = [](0x0)
}
octave:64> a(1,1)="a"
a =
{
[1,1] = a
[2,1] = [](0x0)
[1,2] = [](0x0)
[2,2] = [](0x0)
}
octave:65> a(2,1)="b"
a =
{
[1,1] = a
[2,1] = b
[1,2] = [](0x0)
[2,2] = [](0x0)
}
diary off
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ım daha ileri hazır fonksiyonları içerir.
NEURAL NETWORKS SIMPLIFIED - 2
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.
This section includes more advanced built-in functions.
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
MATRIX UTILITY FUNCTIONS
*******************************************************
octave:2> a=[1,2,3;4,5,6]
a =
1 2 3
4 5 6
octave:3> log(a)
ans =
0.00000 0.69315 1.09861
1.38629 1.60944 1.79176
octave:4> a=[-1,-2,3;4,-5,-6]
a =
-1 -2 3
4 -5 -6
octave:5> abs(a)
ans =
1 2 3
4 5 6
octave:6> exp(a)
ans =
3.6788e-001 1.3534e-001 2.0086e+001
5.4598e+001 6.7379e-003 2.4788e-003
octave:7> sum(a)
ans =
3 -7 -3
octave:8> a
a =
-1 -2 3
4 -5 -6
octave:9> sumsq(a)
ans =
17 29 45
octave:10> a=[4,9]
a =
4 9
octave:11> sqrt(a)
ans =
2 3
octave:12> mod(a,2)
ans =
0 1
octave:13> mod(3,2)
ans = 1
octave:14> floor ([-2.7, 2.7])
ans =
-3 2
octave:15> floor(3.4)
ans = 3
octave:16> ceil(3.4)
ans = 4
octave:17> ceil([-2.7,2.7])
ans =
-2 3
octave:18> realmax()
ans = 1.7977e+308
octave:19> a=[1,2,3;4,5,6;7,8,9]
a =
1 2 3
4 5 6
7 8 9
octave:20> bsxfun(@minus, a,2)
ans =
-1 0 1
2 3 4
5 6 7
octave:21> a=[3,1,5;3,4,2;7,3,5]
a =
3 1 5
3 4 2
7 3 5
octave:22> sort(a)
ans =
3 1 2
3 3 5
7 4 5
octave:23> a
a =
3 1 5
3 4 2
7 3 5
octave:24> sort ([1, 2; 2, 3; 3, 1])
ans =
1 1
2 2
3 3
octave:25> [s, i] = sort ([1, 2; 2, 3; 3, 1])
s =
1 1
2 2
3 3
i =
1 3
2 1
3 2
octave:26> [s, i] = sort ([1, 2; 2, 3; 3, 1], 'descend');
octave:27> s
s =
3 3
2 2
1 1
octave:28> i
i =
3 2
2 1
1 3
octave:29> a
a =
3 1 5
3 4 2
7 3 5
octave:30> mean(a)
ans =
4.3333 2.6667 4.0000
octave:31> find(a==2)
ans = 8
octave:32> a(8)
ans = 2
octave:33> a=[1,1;1,1]
a =
1 1
1 1
octave:34> inv(a)
warning: inverse: matrix singular to machine precision, rcond = 0
ans =
Inf Inf
Inf Inf
octave:35> pinv(a)
ans =
0.25000 0.25000
0.25000 0.25000
octave:36> a=[1,2,3;4,5,6]
a =
1 2 3
4 5 6
octave:37> pinv(a)
ans =
-0.94444 0.44444
-0.11111 0.11111
0.72222 -0.22222
octave:38> a=[1,2,3;4,5,6;7,8,9]
a =
1 2 3
4 5 6
7 8 9
octave:39> X=[ones(3,1) a]
X =
1 1 2 3
1 4 5 6
1 7 8 9
octave:40> b=[1;2;3]
b =
1
2
3
octave:41> a(2,:) = b
a =
1 2 3
1 2 3
7 8 9
octave:42> a
a =
1 2 3
1 2 3
7 8 9
octave:43> a(2,:) = b'
a =
1 2 3
1 2 3
7 8 9
octave:44> Y=[a(:) ; b(:)]
Y =
1
1
7
2
2
8
3
3
9
1
2
3
octave:45> find(a>3)
ans =
3
6
9
octave:46> a
a =
1 2 3
1 2 3
7 8 9
octave:47> ndx=find(a>3)
ndx =
3
6
9
octave:48> for i=1:length(ndx)
> a(ndx(i)) = 1;
> end
octave:49> a
a =
1 2 3
1 2 3
1 1 1
octave:50>
octave:50> a=[1.2,3.4,5.0]
a =
1.2000 3.4000 5.0000
octave:51> round(a)
ans =
1 3 5
octave:52> randperm(3,4)
ans =
2 3 1
1 2 3
1 3 2
2 1 3
octave:53> randperm(3)
ans =
2 1 3
octave:54> a=cell(2,4)
a =
{
[1,1] = [](0x0)
[2,1] = [](0x0)
[1,2] = [](0x0)
[2,2] = [](0x0)
[1,3] = [](0x0)
[2,3] = [](0x0)
[1,4] = [](0x0)
[2,4] = [](0x0)
}
octave:55> a(1,1)=5
a =
{
[1,1] = 5
[2,1] = [](0x0)
[1,2] = [](0x0)
[2,2] = [](0x0)
[1,3] = [](0x0)
[2,3] = [](0x0)
[1,4] = [](0x0)
[2,4] = [](0x0)
}
octave:59> a=["a","b"]
a = ab
octave:60> a(1,1)
ans = a
octave:61> a(1,2)
ans = b
octave:62> a
a = ab
octave:63> a=cell(2)
a =
{
[1,1] = [](0x0)
[2,1] = [](0x0)
[1,2] = [](0x0)
[2,2] = [](0x0)
}
octave:64> a(1,1)="a"
a =
{
[1,1] = a
[2,1] = [](0x0)
[1,2] = [](0x0)
[2,2] = [](0x0)
}
octave:65> a(2,1)="b"
a =
{
[1,1] = a
[2,1] = b
[1,2] = [](0x0)
[2,2] = [](0x0)
}
diary off
Tuesday, 21 August 2018
Neural Networks Simplified - 1
BASİTLEŞTİRİLMİŞ YAPAY SİNİR AĞLARI - 1
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.
NEURAL NETWORKS SIMPLIFIED - 1
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.
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
MATRIX DEFINITIONS
***************************************
a is a 2 x 3 matrix. a has 2 rows and 3 columns.
a 2 x 3 bir matristir. a'nın iki satırı ve 3 sütunu vardır.
octave:65> a=[1,2,3;4,5,6]
a =
1 2 3
4 5 6
octave:66> size(a)
ans =
2 3
An other matrix definition statement is: a(beg : end)
Bir başka matris tanımlama komutu: a(baş : son)
octave:73> a=(-1:3)
a =
-1 0 1 2 3
An other matrix definition statement is: a(beg :increment : end)
Bir başka matris tanımlama komutu: a(baş : arttırım adımı : son)
octave:75> a=(-1:0.5:2)
a =
-1.0000 -0.5000 0.0000 0.5000 1.0000 1.5000 2.0000
An other matrix definition statement is: linspace(beg : step count : end)
Bir başka matris tanımlama komutu: linspace(baş : adım sayısı : son)
octave:77> a=linspace(1,0.5,3)
a =
1.00000 0.75000 0.50000
octave:78> a=linspace(1,3,3)
a =
1 2 3
octave:79> a=linspace(1,3,4)
a =
1.0000 1.6667 2.3333 3.0000
MATRIX ELEMENT ADDRESSING
MATRİS ELEMAN ADRESLEME
***************************************
octave:84> a=[1,2,3;4,5,6]
a =
1 2 3
4 5 6
octave:85> a(1)
ans = 1
octave:86> a(1:4)
ans =
1 4 2 5
octave:87> a(1:6)
ans =
1 4 2 5 3 6
octave:88> a(1:2,1)
ans =
1
4
octave:89> a(1:2,3)
ans =
3
6
octave:90> a(1:2,[1 3])
ans =
1 3
4 6
octave:91> a(1:2,1:3)
ans =
1 2 3
4 5 6
octave:92> a(1:2,:)
ans =
1 2 3
4 5 6
octave:93> a(:,1:2)
ans =
1 2
4 5
octave:94> a(1,1:3)
ans =
1 2 3
octave:95> a(:,:)
ans =
1 2 3
4 5 6
octave:104> a=[1,2,3;4,5,6;7,8,9]
a =
1 2 3
4 5 6
7 8 9
octave:106> b=[1,2]
b =
1 2
octave:107> a(b,:)
ans =
1 2 3
4 5 6
octave:108> a(1,:)
ans =
1 2 3
BASIC MATRIX FUNCTIONS
***************************************
octave:2> ndims([1,2;3,4])
ans = 2
octave:10> ones(2,3)
ans =
1 1 1
1 1 1
octave:11> zeros(1,2)
ans =
0 0
octave:12> eye(1,3)
ans =
Diagonal Matrix
1 0 0
octave:13> eye(3)
ans =
Diagonal Matrix
1 0 0
0 1 0
0 0 1
octave:14> a = 13; a(ones (1, 4))
ans =
13 13 13 13
octave:17> rand(3)
ans =
0.61503 0.73559 0.16378
0.11622 0.89969 0.96928
0.16057 0.14347 0.84992
octave:14> a = 13;
octave:18> size(a)
ans =
1 1
octave:19> a=[1,2;3,4;5,6]
a =
1 2
3 4
5 6
octave:20> size(a)
ans =
3 2
octave:21> b=1
b = 1
octave:22> size(b)
ans =
1 1
octave:2> zeros(1)
ans = 0
octave:3> zeros(2,2)
ans =
0 0
0 0
octave:4> zeros(2,3)
ans =
0 0 0
0 0 0
octave:5> a=[1,2;3,4;5,6]
a =
1 2
3 4
5 6
octave:6> zeros(size(a))
ans =
0 0
0 0
0 0
octave:7> size(a)
ans =
3 2
octave:8> eye(0)
ans = [](0x0)
octave:9> eye(1)
ans = 1
octave:10> eye(2)
ans =
Diagonal Matrix
1 0
0 1
octave:11> eye(2,3)
ans =
Diagonal Matrix
1 0 0
0 1 0
octave:12> ones(0)
ans = [](0x0)
octave:13> ones(1)
ans = 1
octave:14> ones(2)
ans =
1 1
1 1
octave:15> ones(2,3)
ans =
1 1 1
1 1 1
octave:16> rand(0)
ans = [](0x0)
octave:17> rand(1)
ans = 0.76538
octave:18> rand(1)
ans = 0.74158
octave:19> rand(2)
ans =
0.62458 0.30045
0.48308 0.36512
octave:62> rand(2)
ans =
0.148336 0.481660
0.082268 0.182176
octave:20> rand(2,3)
ans =
0.056270 0.180314 0.794059
0.905070 0.366595 0.562126
octave:21> a=[1,2;3,4]
a =
1 2
3 4
octave:22> size(a)
ans =
2 2
octave:23> b=[1,2,3;4,5,6]
b =
1 2 3
4 5 6
octave:24> size(b)
ans =
2 3
octave:25> length(b)
ans = 3
octave:26> length(a)
ans = 2
octave:27> c=[1,2,3,4,5]
c =
1 2 3 4 5
octave:28> length(c)
ans = 5
octave:29> max(c)
ans = 5
octave:30> max(b)
ans =
4 5 6
octave:31> max(a)
ans =
3 4
octave:32> min(c)
ans = 1
octave:33> min(b)
ans =
1 2 3
octave:34> min(a)
ans =
1 2
octave:35> d=[2,3,1,5,6,4]
d =
2 3 1 5 6 4
octave:36> min(d)
ans = 1
octave:37> max(d)
ans = 6
octave:38> d=[2,3,1,5,6,4;1,2,3,4,5,6]
d =
2 3 1 5 6 4
1 2 3 4 5 6
octave:39> min(d)
ans =
1 2 1 4 5 4
octave:40> max(d)
ans =
2 3 3 5 6 6
octave:41> numel(d)
ans = 12
octave:42> numel(c)
ans = 5
octave:43> numel(b)
ans = 6
octave:44> numel(a)
ans = 4
norm (A, p, opt)
Compute the p-norm of the matrix A.
If the second argument is missing, p = 2 is assumed.
If A is a matrix (or sparse matrix):
p = 1 1-norm, the largest column sum of the absolute values of A.
p = 2 Largest singular value of A.
octave:45> norm(a)
ans = 5.4650 <===========
octave:46> a
a =
1 2
3 4
octave:49> [U,S,V]=svd(a)
Compute the singular value decomposition of A
A'nın tekil değer ayrıştırımını hesaplayınız.
U =
-0.40455 -0.91451
-0.91451 0.40455
S =
Diagonal Matrix
5.46499 0 <===========
0 0.36597
V =
-0.57605 0.81742
-0.81742 -0.57605
octave:50> b
b =
1 2 3
4 5 6
octave:51> [U,S,V]=svd(b)
U =
-0.38632 -0.92237
-0.92237 0.38632
S =
Diagonal Matrix
9.50803 0 0 <===========
0 0.77287 0
V =
-0.42867 0.80596 0.40825
-0.56631 0.11238 -0.81650
-0.70395 -0.58120 0.40825
octave:52> norm(b)
ans = 9.5080 <===========
octave:53> c
c =
1 2 3 4 5
octave:54> [U,S,V]=svd(c)
U = 1
S =
Diagonal Matrix
7.4162 0 0 0 0 <===========
V =
0.134840 -0.269680 -0.404520 -0.539360 -0.674200
0.269680 0.935914 -0.096129 -0.128172 -0.160215
0.404520 -0.096129 0.855807 -0.192258 -0.240322
0.539360 -0.128172 -0.192258 0.743656 -0.320430
0.674200 -0.160215 -0.240322 -0.320430 0.599463
octave:55> norm(c)
ans = 7.4162 <===========
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.
NEURAL NETWORKS SIMPLIFIED - 1
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.
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
MATRIX DEFINITIONS
***************************************
a is a 2 x 3 matrix. a has 2 rows and 3 columns.
a 2 x 3 bir matristir. a'nın iki satırı ve 3 sütunu vardır.
octave:65> a=[1,2,3;4,5,6]
a =
1 2 3
4 5 6
octave:66> size(a)
ans =
2 3
An other matrix definition statement is: a(beg : end)
Bir başka matris tanımlama komutu: a(baş : son)
octave:73> a=(-1:3)
a =
-1 0 1 2 3
An other matrix definition statement is: a(beg :increment : end)
Bir başka matris tanımlama komutu: a(baş : arttırım adımı : son)
octave:75> a=(-1:0.5:2)
a =
-1.0000 -0.5000 0.0000 0.5000 1.0000 1.5000 2.0000
An other matrix definition statement is: linspace(beg : step count : end)
Bir başka matris tanımlama komutu: linspace(baş : adım sayısı : son)
octave:77> a=linspace(1,0.5,3)
a =
1.00000 0.75000 0.50000
octave:78> a=linspace(1,3,3)
a =
1 2 3
octave:79> a=linspace(1,3,4)
a =
1.0000 1.6667 2.3333 3.0000
MATRIX ELEMENT ADDRESSING
MATRİS ELEMAN ADRESLEME
***************************************
octave:84> a=[1,2,3;4,5,6]
a =
1 2 3
4 5 6
octave:85> a(1)
ans = 1
octave:86> a(1:4)
ans =
1 4 2 5
octave:87> a(1:6)
ans =
1 4 2 5 3 6
octave:88> a(1:2,1)
ans =
1
4
octave:89> a(1:2,3)
ans =
3
6
octave:90> a(1:2,[1 3])
ans =
1 3
4 6
octave:91> a(1:2,1:3)
ans =
1 2 3
4 5 6
octave:92> a(1:2,:)
ans =
1 2 3
4 5 6
octave:93> a(:,1:2)
ans =
1 2
4 5
octave:94> a(1,1:3)
ans =
1 2 3
octave:95> a(:,:)
ans =
1 2 3
4 5 6
octave:104> a=[1,2,3;4,5,6;7,8,9]
a =
1 2 3
4 5 6
7 8 9
octave:106> b=[1,2]
b =
1 2
octave:107> a(b,:)
ans =
1 2 3
4 5 6
octave:108> a(1,:)
ans =
1 2 3
BASIC MATRIX FUNCTIONS
***************************************
octave:2> ndims([1,2;3,4])
ans = 2
octave:10> ones(2,3)
ans =
1 1 1
1 1 1
octave:11> zeros(1,2)
ans =
0 0
octave:12> eye(1,3)
ans =
Diagonal Matrix
1 0 0
octave:13> eye(3)
ans =
Diagonal Matrix
1 0 0
0 1 0
0 0 1
octave:14> a = 13; a(ones (1, 4))
ans =
13 13 13 13
octave:17> rand(3)
ans =
0.61503 0.73559 0.16378
0.11622 0.89969 0.96928
0.16057 0.14347 0.84992
octave:14> a = 13;
octave:18> size(a)
ans =
1 1
octave:19> a=[1,2;3,4;5,6]
a =
1 2
3 4
5 6
octave:20> size(a)
ans =
3 2
octave:21> b=1
b = 1
octave:22> size(b)
ans =
1 1
octave:2> zeros(1)
ans = 0
octave:3> zeros(2,2)
ans =
0 0
0 0
octave:4> zeros(2,3)
ans =
0 0 0
0 0 0
octave:5> a=[1,2;3,4;5,6]
a =
1 2
3 4
5 6
octave:6> zeros(size(a))
ans =
0 0
0 0
0 0
octave:7> size(a)
ans =
3 2
octave:8> eye(0)
ans = [](0x0)
octave:9> eye(1)
ans = 1
octave:10> eye(2)
ans =
Diagonal Matrix
1 0
0 1
octave:11> eye(2,3)
ans =
Diagonal Matrix
1 0 0
0 1 0
octave:12> ones(0)
ans = [](0x0)
octave:13> ones(1)
ans = 1
octave:14> ones(2)
ans =
1 1
1 1
octave:15> ones(2,3)
ans =
1 1 1
1 1 1
octave:16> rand(0)
ans = [](0x0)
octave:17> rand(1)
ans = 0.76538
octave:18> rand(1)
ans = 0.74158
octave:19> rand(2)
ans =
0.62458 0.30045
0.48308 0.36512
octave:62> rand(2)
ans =
0.148336 0.481660
0.082268 0.182176
octave:20> rand(2,3)
ans =
0.056270 0.180314 0.794059
0.905070 0.366595 0.562126
octave:21> a=[1,2;3,4]
a =
1 2
3 4
octave:22> size(a)
ans =
2 2
octave:23> b=[1,2,3;4,5,6]
b =
1 2 3
4 5 6
octave:24> size(b)
ans =
2 3
octave:25> length(b)
ans = 3
octave:26> length(a)
ans = 2
octave:27> c=[1,2,3,4,5]
c =
1 2 3 4 5
octave:28> length(c)
ans = 5
octave:29> max(c)
ans = 5
octave:30> max(b)
ans =
4 5 6
octave:31> max(a)
ans =
3 4
octave:32> min(c)
ans = 1
octave:33> min(b)
ans =
1 2 3
octave:34> min(a)
ans =
1 2
octave:35> d=[2,3,1,5,6,4]
d =
2 3 1 5 6 4
octave:36> min(d)
ans = 1
octave:37> max(d)
ans = 6
octave:38> d=[2,3,1,5,6,4;1,2,3,4,5,6]
d =
2 3 1 5 6 4
1 2 3 4 5 6
octave:39> min(d)
ans =
1 2 1 4 5 4
octave:40> max(d)
ans =
2 3 3 5 6 6
octave:41> numel(d)
ans = 12
octave:42> numel(c)
ans = 5
octave:43> numel(b)
ans = 6
octave:44> numel(a)
ans = 4
norm (A, p, opt)
Compute the p-norm of the matrix A.
If the second argument is missing, p = 2 is assumed.
If A is a matrix (or sparse matrix):
p = 1 1-norm, the largest column sum of the absolute values of A.
p = 2 Largest singular value of A.
octave:45> norm(a)
ans = 5.4650 <===========
octave:46> a
a =
1 2
3 4
octave:49> [U,S,V]=svd(a)
Compute the singular value decomposition of A
A'nın tekil değer ayrıştırımını hesaplayınız.
U =
-0.40455 -0.91451
-0.91451 0.40455
S =
Diagonal Matrix
5.46499 0 <===========
0 0.36597
V =
-0.57605 0.81742
-0.81742 -0.57605
octave:50> b
b =
1 2 3
4 5 6
octave:51> [U,S,V]=svd(b)
U =
-0.38632 -0.92237
-0.92237 0.38632
S =
Diagonal Matrix
9.50803 0 0 <===========
0 0.77287 0
V =
-0.42867 0.80596 0.40825
-0.56631 0.11238 -0.81650
-0.70395 -0.58120 0.40825
octave:52> norm(b)
ans = 9.5080 <===========
octave:53> c
c =
1 2 3 4 5
octave:54> [U,S,V]=svd(c)
U = 1
S =
Diagonal Matrix
7.4162 0 0 0 0 <===========
V =
0.134840 -0.269680 -0.404520 -0.539360 -0.674200
0.269680 0.935914 -0.096129 -0.128172 -0.160215
0.404520 -0.096129 0.855807 -0.192258 -0.240322
0.539360 -0.128172 -0.192258 0.743656 -0.320430
0.674200 -0.160215 -0.240322 -0.320430 0.599463
octave:55> norm(c)
ans = 7.4162 <===========
Subscribe to:
Posts (Atom)