nn2.m

来自「this demo on neural network creation」· M 代码 · 共 18 行

M
18
字号
function output=NN2(weights,inputs,af)
%weights is generated from NN2weights
%input is a column vector of input values
%af is either p for perceptron or anything else for logistic function
output=zeros(1,weights.outputnum);
alpha=weights.inputs*inputs+weights.bias;
for n=1:weights.outputnum
    if (af=='p')
        if (alpha(n)>0)
            output(n)=1;
        else 
            output(n)=0;
        end
    else
        output(n)=(1+exp(-alpha(n)))^-1;
    end
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?