-
Notifications
You must be signed in to change notification settings - Fork 19.6k
Description
Dear Keras team,
Conv2D layer no longer supports Masking layer in TensorFlow v2.17.0. I've already raised this issue with TensorFlow. However, they requested that I raise the issue here.
Due the dimensions of our input (i.e. (timesteps, width, channels)), size of the input shape (i.e. (2048, 2000, 3)) and size of the dataset (i.e. over 1 million samples), it is not practical to use LSTM, GRU, RNN or ConvLSTM1D layers, and therefore, Conv2D layers worked sufficiently well in our applications. The gaps in the dataset was handled with the Masking layer, and the masking layer was compatible with the Conv layers (among other layers, such as Cropping and Padding) from all TF versions up to (and including) TF v2.16. However, in TF v2.17.0, we get the following user warning "Layer 'conv2d' (of type Conv2D) was passed an input with a mask attached to it. However, this layer does not support masking and will therefore destroy the mask information. Downstream layers will not see the mask".
Is this a bug in TF v2.17.0?
Or is this feature now depreciated in TF v2.17.0?
Would you be able to reintroduce this feature in future versions?
Best
Kav
LINK TO THE CODE ON COLAB NOTEBOOK:
https://colab.research.google.com/drive/102k6UNSKb-d03DcmcUtCxmV9Qz9bjZoD?usp=drive_link
STANDALONE CODE:
from tensorflow.keras.layers import Conv2D, Masking, Flatten
from tensorflow.keras import Model, Input
batch = 1
timesteps = 10
width = 10
channels = 2
filters = 4
kernel_size = 3
mask_value = -1
x_input = Input(shape=(timesteps, width, channels))
x_masking = Masking(mask_value)(x_input)
x_conv2d = Conv2D(filters, kernel_size)(x_masking)
x_flatten = Flatten()(x_conv2d)
model = Model(x_input, x_flatten)
model.compile(loss='mse')
RELEVANT LOG OUTPUT
/usr/local/lib/python3.10/dist-packages/keras/src/layers/layer.py:915: UserWarning: Layer 'conv2d' (of type Conv2D) was passed an input with a mask attached to it. However, this layer does not support masking and will therefore destroy the mask information. Downstream layers will not see the mask.
warnings.warn(
LINK TO THE ORIGINAL RAISED ISSUE ON TENSORFLOW REPO
tensorflow/tensorflow#73531