I am having trouble extracting the output of an intermediate layer in a Keras NN model. Although there is a ton of resource on this most of them are geared towards for python users. I have tried working towards the tutorial posted here and here. Essentially both of the tutorial says to recreate the original model and then somehow extract the intermediate layers by simply calling it. The issue I am having is model$input
returns nothing in my code and I have no idea where layer_name
is in a model. After playing around with this method I tried creating a new model to the layer I am interested in and put in the trained weights of the original model in order to get the intermediate layer output. However, I found myself at a lack of resource for R users on how to place weights into a new model. I would appreciate if anyone would help with walking through a concrete example on how to do either method or a better one. Here is my original model:
network <- keras_model_sequential()
network %>%
layer_dropout(rate = 0.1) %>%
layer_dense(units = 64, activation = "relu", input_shape = length(training_data) ) %>%
layer_dense(units = 8, activation = "sigmoid" ) %>%
layer_dense(units = 64, activation = "relu" ) %>%
layer_dense(units = length(training_data), activation = "softmax")
question from:
https://stackoverflow.com/questions/66053383/how-to-extract-the-output-of-an-intermediate-layer-in-keras-for-r 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…