Keras I want to get the output of any layer !!

Introduction

Describes how to get the output of any layer in the network with Keras.

Implementation example

predict.py


from keras import backend as K
get_1st_layer_output = K.function([model.layers[0].input],
                                  [model.layers[5].output])

layer_output = get_1st_layer_output([img,])
img_layer_5 = layer_output[0][0,:]

Implementation example (Explanation)

Specify the input layer and the layer you want to get in the argument of K.finction (). Create a function. If you give the function an input (here, an image) as an argument, the layer you want to get You can get the output !!

Recommended Posts

Keras I want to get the output of any layer !!
I want to get the operation information of yahoo route
I want to output to the console coolly
I want to get the name of the function / method being executed
I want to output the beginning of the next month with Python
I want to get League of Legends data ③
I want to customize the appearance of zabbix
I want to get League of Legends data ①
I want to fully understand the basics of Bokeh
I want to increase the security of ssh connections
I want to get the path of the directory where the running file is stored.
[NNabla] How to get the output (variable) of the middle layer of a pre-built network
I tried to get the location information of Odakyu Bus
I want to use only the normalization process of SudachiPy
I want to take a screenshot of the site on Docker using any font
I want to judge the authenticity of the elements of numpy array
I want to know the features of Python and pip
I want to know the legend of the IT technology world
I want to output a beautifully customized heat map of the correlation matrix. matplotlib edition
I want to manually assign the training parameters of the [Pytorch] model
I want to read the html version of "OpenCV-Python Tutorials" OpenCV 3.1 version
I want to check the position of my face with OpenCV!
I want to know the population of each country in the world.
I want to pin Spyder to the taskbar
I want to handle the rhyme part1
I want to handle the rhyme part3
How to get colored output to the console
I want to display the progress bar
Get the value of the middle layer of NN
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
I tried to get the batting results of Hachinai using image processing
[Note] I want to completely preprocess the data of the Titanic issue-Age version-
I don't want to admit it ... The dynamical representation of Neural Networks
(Python Selenium) I want to check the settings of the download destination of WebDriver
I measured 6 methods to get the index of the maximum value (minimum value) of the list
I want to batch convert the result of "string" .split () in Python
I want to explain the abstract class (ABCmeta) of Python in detail.
I tried to get the authentication code of Qiita API with Python.
I want to express my feelings with the lyrics of Mr. Children
I want to analyze the emotions of people who want to meet and tremble
I want to use the Qore SDK to predict the success of NBA players
I want to leave an arbitrary command in the command history of Shell
I tried to get the RSS of the top song of the iTunes store automatically
I want to stop the automatic deletion of the tmp area with RHEL7
Python: I want to measure the processing time of a function neatly
[For beginners] I want to get the index of an element that satisfies a certain conditional expression
Setting to output the log of cron execution
I want to handle the rhyme part7 (BOW)
I tried to touch the API of ebay
I tried to correct the keystone of the image
To get the path of the currently running python.exe
I want to use the activation function Mish
I want to display the progress in Python!
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
[Python] I tried to judge the member image of the idol group using Keras
The story of IPv6 address that I want to keep at a minimum
I want to use Python in the environment of pyenv + pipenv on Windows 10
I want to use PyTorch to generate something like the lyrics of Japari Park