I wan to re-write TensorFlow code into Keras. I just wonder if you can use for this purpose the tf.keras.layers
to just replace the tf.layers
?
Like
tf.layers.max_pooling2d()
to:
tf.keras.layers.max_pooling2d()
Can I re-write TensorFlow to Keras in this way?
Does this define a proper Keras model where you can use the model.fit
method?
First of all, I think you meant tf.keras.layers.MaxPool2D
, which is a class, not a function. If I got your point, it shouldn't be an issue. There are some minor difference in syntax, but nothing serious. Besides, tf.keras.layers
is a direct substitute for tf.layers
. As per official docs, tf.layers
are wrappers around tf.keras.layers. For example , convolutional layers in Layers API inherit from tf.keras.layers
.
@tf_export('layers.Conv1D')
class Conv1D(keras_layers.Conv1D, base.Layer):
"""1D convolution layer (e.g. temporal convolution).
Even more so, Layers API is deprecated and will be removed from TF 2.0.
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.