R, keras: How to get output of a hidden layer? I am using package Keras in R to do a neural network. How may I extract the output from a hidden layer? I found an example in python, but it is just I have no idea how to do that in R.
You can get the answer here.
Here it is:
model &lt;- ...  # create the original model
layer_name &lt;- 'my_layer'
intermediate_layer_model &lt;- keras_model(inputs = model$input,
                                    outputs = get_layer(model, layer_name)$output)
intermediate_output &lt;- predict(intermediate_layer_model, data)