keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.34k stars 19.39k forks source link

Request for groups parameter support in Conv2DTranspose/Conv1DTranspose Layer #19871

Open PhyllisJi opened 1 month ago

PhyllisJi commented 1 month ago

Issue type

Support

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

binary

TensorFlow version

tf 2.14.0

Custom code

Yes

OS platform and distribution

Ubuntu 20.04

Mobile device

No response

Python version

3.10

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

I request the addition of the groups parameter to the tf.keras.layers.Conv2DTranspose layer. This feature is crucial for the following reasons:

Enhanced Model Flexibility and Efficiency: The groups parameter allows for the implementation of grouped transposed convolutions, which can significantly enhance model flexibility and computational efficiency. By splitting the input and output channels into separate groups, it enables the creation of more complex and diverse neural network architectures, such as those found in state-of-the-art models like ResNeXt and MobileNetV2. Consistency with Other Frameworks: PyTorch, a widely used deep learning framework, supports the groups parameter in its ConvTranspose2d layer. Including this feature in TensorFlow would align its functionality with PyTorch, facilitating easier migration of models between these frameworks and enhancing interoperability for developers and researchers. Optimization of Computational Resources: Grouped convolutions are known to reduce the number of parameters and computational load, which is particularly beneficial for deploying models on resource-constrained devices such as mobile phones and embedded systems. By supporting the groups parameter, TensorFlow can better cater to the needs of edge computing and real-time inference applications. Broadening Application Scope:

The ability to use grouped transposed convolutions would broaden the scope of applications that TensorFlow can effectively handle, including tasks that require fine-grained control over the convolution operations, such as generative adversarial networks (GANs) and super-resolution models. Adding groups support to the Conv2DTranspose layer would greatly enhance the usability and versatility of TensorFlow. It would provide developers with a powerful tool for building efficient and advanced neural network architectures, aligning TensorFlow with industry standards and best practices.

Standalone code to reproduce the issue

Current:

tf.keras.layers.Conv1DTranspose(
    filters,
    kernel_size,
    strides=1,
    padding='valid',
    data_format=None,
    dilation_rate=1,
    activation=None,
    use_bias=True,
    kernel_initializer='glorot_uniform',
    bias_initializer='zeros',
    kernel_regularizer=None,
    bias_regularizer=None,
    activity_regularizer=None,
    kernel_constraint=None,
    bias_constraint=None,
    **kwargs
)
jeffcarp commented 4 weeks ago

How straightforward is the implementation of this? Look like in base Conv2D it's used here: https://github.com/keras-team/keras/blob/d20f4a73f4a952cd143d123028face90dcc2186d/keras/src/layers/convolutional/base_conv.py#L187C1-L187C42