Closed XiangLiu-github closed 3 years ago
Hi, I'm glad you like the package. You can use the method "partialForward" for this. See the below snippet
library(ANN2)
X <- iris[,1:4]
y <- iris$Species
nn <- neuralnetwork(X, y, hidden.layers = c(3, 4, 5))
row <- as.matrix(X[1,])
for (layer_idx in 1:nn$Rcpp_ANN$getMeta()$n_hidden) {
act <- nn$Rcpp_ANN$partialForward(row, 0, layer_idx)
print(act)
}
Thanks! I noticed that there are other functions under nn$Rcpp_ANN, it might be helpful if you could provide more description about it.
I have another question that can I obtain the 'presoftmax' results from a muticlassification model? The predict function only returns the probability that is scaled by softmax.
There is no method for it. But you can obtain the outputs of the preceding layer, then multiply with the weights and add the biases. The weights and biases you obtain from the ANN object using NN$Rcpp_ANN$getParams()
Hi
Thanks for this package, I am trying to interpret the artificial neural network using a method called 'layer-wise relevance propagation', I knew python can do it, but in R I need to do the manual calculations that need the individual activations of each unit in each hidden layer. Do you have any idea how I can obtain the activations from the 'ann' object?
Thanks.