function [ onet ] = netlearn( net, input, target, runs )

%input - vstupni signaly ve radcich

f = @(x) sigmf(x, [10 .5]); %sigmoid funkce
fa = @(x) (f(x)-f(x-0.001))/0.001;  %derivace funkci sigmoid

%krok 1
while (1)
    
%krok 2
    for i = 1:size(input,1)

        %krok 3
        x = input(i,:)';
        t = target(i,:)';

        %krok 4
        z_in = net.v'*x + net.v0;
        z = f(z_in);

        %krok 5
        y_in = net.w0 + net.w'*z;
        y = f(y_in);

        %krok 6
        delta = (t-y).*fa(y_in);
        deltaw = net.alfa.*(z*delta');
        deltaw0 = net.alfa.*delta;

        %krok7
        delta_in = net.w*delta;
        delta = delta_in.*fa(z_in);
        deltav = net.alfa.*(x*delta');
        deltav0 = net.alfa.*delta;

        %krok8
        net.w = net.w + deltaw;
        net.v = net.v + deltav;
        net.w0 = net.w0 + deltaw0;
        net.v0 = net.v0 + deltav0;

    end
    runs=runs-1;
    if (runs<=0)
        break;
    end
end

onet=net;
end

