如何在 Octave 中实现 sigmoid 函数?

数据挖掘 回归 逻辑回归 八度
2021-09-25 05:37:44

因此,鉴于 sigmoid 函数定义为 hθ(x) = g(θ^(T)x),如果 g = zeros(size(z)),我如何在 Octave 中实现这个函数?

1个回答

这将计算标量、向量或矩阵的 sigmoid。

function g = sigmoid(z)
%   SIGMOID Compute sigmoid function
%   g = SIGMOID(z) computes the sigmoid of z.


% Compute the sigmoid of each value of z (z can be a matrix,
% vector or scalar).

SIGMOID = @(z) 1./(1 + exp(-z));

g = SIGMOID(z);

end