Skip to content

Instantly share code, notes, and snippets.

@echo66
Created February 1, 2017 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save echo66/28c91deace841010f74edd12c146ac80 to your computer and use it in GitHub Desktop.
Save echo66/28c91deace841010f74edd12c146ac80 to your computer and use it in GitHub Desktop.
x = -10:0.01:10;
function y = logistic(z)
y = 1 ./ (1 + e.^(-z));
end
function y = logistic_derivative(z)
y = logistic(z) .* (1 - logistic(z));
end
y1 = logistic(x);
dy1 = logistic_derivative(x);
y2 = tanh(x);
dy2 = 1 - tanh(x).^2;
figureplot(x, y1, "-;logistic(z);", x, y2, "-;tanh(z);");
figureplot(x, dy1, "-;logistic derivative;", x, dy2, "-;tanh derivative;");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment