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