简体   繁体   中英

How to use a layer the same way you use function in Keras?

I'm a student and beginner with Keras. I wonder how to use a layer such in the same way of a python function. I want to define a layers, a Dense one, for example, and then be able to compute the image of an x given by the layer.

Thanks and have a good day.

So first, take a look at Keras Functional API . That way you can do something like this:

from keras.layers import *

# load some data into x
x = load()

dense_output = Dense(4096, activation='relu')(x)
dropout_output = Dropout(0.3)(dense_output)   
...

You can do basically everything you need with Functional API. I hope this clarifies the situation for you :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM