Hamid Heydarian
Hamid Heydarian

Reputation: 912

tf.layers.Conv1D vs tf.keras.layers.Conv1D

I was using tf.layers.conv1d found in this tutorial but then realised it's been deprecated. Then I discovered tf.layers.Conv1D and tf.keras.layers.Conv1D. I understand the later one is the keras implementation of one dimensional convolutional layer. I'm however not sure which one to use and what's the difference in terms of functionality. It would be great of someone could point out examples of using any of these two where the input data comes from csv files.

Upvotes: 0

Views: 1254

Answers (1)

Sharky
Sharky

Reputation: 4533

First of all, Layers API is deprecated and will be removed from TF 2.0. keras.layers is a direct substitute, because it will be the main high level api for future version. As per official docs, tf.layers are wrappers around tf.keras.layers. Convolutional layers in Layers API inherit from tf.keras.layers. From tensorflow/python/layers/convolutional.py:

@tf_export('layers.Conv1D')
class Conv1D(keras_layers.Conv1D, base.Layer):
  """1D convolution layer (e.g. temporal convolution). 

TensorFlow layers cannot be used directly within a Keras model, as it they miss some attributes required by the Keras API. However, it is possible to use them with Keras Lambda layer.

Upvotes: 1

Related Questions