标签:
sigmoid.m文件
function g = sigmoid(z)
%SIGMOID Compute sigmoid functoon
% J = SIGMOID(z) computes the sigmoid of z.
g = zeros(size(z)); 初始化g ,z可以是一个数,一个向量或者一个矩阵
% ====================== YOUR CODE HERE ======================
% Instructions: Compute the sigmoid of each value of z (z can be a matrix, vector or scalar)
Ones = ones(size(z));
g = Ones./(Ones + exp((-1).*z)); 计算,
当z=0时,g=0.5; 当z<0时,g<0.5;当z>0时,g>0.5;
当z->-∞时,g->0; 当z->+∞时,g->1
z可以是一个数,一个向量或者是一个矩阵
% =============================================================
end
标签:
原文地址:http://www.cnblogs.com/yan2015/p/4826635.html