如何在Octave中实现S形函数?[关闭]


Answers:


6

这将计算标量,向量或矩阵的S形。

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

正在使用“ /”代替“ ./”。我非常非常糟糕。
Yogesh Sanchihar

2
您可以使用g = 1 ./ (1 + exp(-z));而不是SIGMOIDsigmoid函数内部创建它。
Alisson
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.