感知器中的超平面

时间:2016-12-27 01:53:28

标签: neural-network perceptron

在讨论神经网络和感知器时,什么是超平面?

使用Hyperplane实现以下感知器。

perceptron_minin.m (八度)

function [errors, sepplane ] = perceptron_minin ( pclass , nclass)
    sepplane = rand ( 1 , columns ( pclass ) + 1 ) - 0.5;
    tset = [ones(rows(pclass), 1),  pclass ; -ones(rows(nclass), 1), -nclass];
    i = 1;
    do
        misind = tset * sepplane' < 0;

        correction = sum ( tset ( misind , :), 1 ) / sqrt ( i );

        sepplane = sepplane + correction;

        ++i;
    until ( norm(sepplane) * 0.0005 ) - norm(correction) > 0 || i > 1000);

    errors = mean( tset * sepplane' < 0);
    dzeros = tvec(tlab == 1 , :);
    dones = tvec(tlab == 2 , :);
    perceptron(dzeros, dones)
end

但是,在以下程序中,逻辑的设计不使用超平面。

perceptron_test.m (MATLAB)

bias = -1;
coeff = 0.7;
rand('state', sum(100 * clock));
weights = -1*2 .* rand(3,1);

train_iter = 10000;
train_data_count = 4;
test_data_count  =  100;

%%  training section

train_data = [   0  0; 
                 0  1; 
                 1  0; 
                 1  1];

class_labels = [0;
               1;
               1;
               1];

bias_vector(1:train_data_count, 1) = bias;

train_data_biased = [bias_vector, train_data];

for i=1:train_iter
    output = zeros(train_data_count,1);
    for j=1:train_data_count   
        y = product(train_data_biased(j,:), weights);

        output(j)  = activ_func(y);

        delta = class_labels(j) - output(j);

        inc = train_data_biased(j,:) * (coeff  * delta);

        weights = weights + inc';
    end
end

table(train_data(:,1), train_data(:,2), output, 'VariableNames', {'A' 'B' 'A_xor_B'})


%% test Section

test_data = randi([0 , 1], [test_data_count, 2]) + 
            (2 * rand(test_data_count,2) - 1) / 20;

for i=1:test_data_count
   y = bias*weights(1,1)+...
       test_data(i,1)*weights(2,1)+...
       test_data(i,2)*weights(3,1);
   output(i) = 1/(1+exp(-y));
end

table(test_data(:,1),test_data(:,2), output,
       'VariableNames',{'A' 'B' 'A_xor_B'})

现在,我有几个问题,

(1)第一个源代码是否正确?

(2)如果,请解释为什么它们都有效。

1 个答案:

答案 0 :(得分:0)

权重不是Hyperplane的同义词,但它们是相关的:Hyperplane是由权重值定义的。