1

I can't seem to find any documentation of how to apply a sigmoid function in the neuralnet package, I tried:

neuralnet(...,act.fct="sigmoid")

However this returned;

Error: ''act.fct' is not known
John Meighan
  • 69
  • 1
  • 10

1 Answers1

9

You are looking for the "logistic" for that package.

neuralnet(..., act.fct = "logistic")

That said though, if you have a function that isn't in there (and there aren't many in that package) you can pass the function yourself.

library(neuralnet)

data(infert)

set.seed(123)
net.infert <- neuralnet(case~parity+induced+spontaneous, infert, 
                        err.fct="ce", linear.output=FALSE, likelihood=TRUE)

sigmoid = function(x) {
  1 / (1 + exp(-x))
}

set.seed(123)
net.infert2 <- neuralnet(case~parity+induced+spontaneous, infert, 
                        err.fct="ce", linear.output=FALSE, likelihood=TRUE,
                        act.fct = sigmoid)

all.equal(net.infert$weights, net.infert2$weights)
[1] TRUE
cdeterman
  • 19,630
  • 7
  • 76
  • 100