Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

group conv2d can't backprop properly #15713

Closed
breadbread1984 opened this issue Nov 28, 2021 · 2 comments
Closed

group conv2d can't backprop properly #15713

breadbread1984 opened this issue Nov 28, 2021 · 2 comments
Assignees
Labels
stat:awaiting response from contributor type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited.

Comments

@breadbread1984
Copy link

Please go to TF Forum for help and support:

https://discuss.tensorflow.org/tag/keras

If you open a GitHub issue, here is our policy:

It must be a bug, a feature request, or a significant problem with the documentation (for small docs fixes please send a PR instead).
The form below must be filled out.

Here's why we have that policy:.

Keras developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.

System information.

  • Have I written custom code (as opposed to using a stock example script provided in Keras): no
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): 20.04
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 2.7.0
  • Python version: 3.8.0
  • Bazel version (if compiling from source): n/a
  • GPU model and memory: n/a
  • Exact command to reproduce: n/a

You can collect some of this information using our environment capture script:

https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh

You can obtain the TensorFlow version with:
python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"

v2.7.0-rc1-69-gc256c071bb2 2.7.0

Describe the problem.

Describe the problem clearly here. Be sure to convey here why it's a bug in Keras or why the requested feature is needed.

Describe the current behavior.

Group tf.keras.layers.Conv2D can forward propagate without problem but can't backward propagate properly.

Describe the expected behavior.

Group Conv2D should back propagate properly.

Contributing.

  • Do you want to contribute a PR? (yes/no): no
  • If yes, please read this page for instructions
  • Briefly describe your candidate solution(if contributing):

Standalone code to reproduce the issue.

Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Colab/Jupyter/any notebook.

import tensorflow as tf;

inputs = tf.random.normal(shape = (4,224,224,256));
conv2d = tf.keras.layers.Conv2D(256, (3,3), groups = 4, padding = 'same');
with tf.GradientTape() as tape:
  outputs = conv2d(inputs);
# NOTE: error occurs here
grads = tape.gradient(outputs, conv2d.trainable_variables);

Source code / logs.

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem.

Traceback (most recent call last):
  File "test.py", line 27, in <module>
    grads = tape.gradient(outputs, conv2d.trainable_weights);
  File "/home/xieyi/.local/lib/python3.8/site-packages/tensorflow/python/eager/backprop.py", line 1084, in gradient
    flat_grad = imperative_grad.imperative_grad(
  File "/home/xieyi/.local/lib/python3.8/site-packages/tensorflow/python/eager/imperative_grad.py", line 71, in imperative_grad
    return pywrap_tfe.TFE_Py_TapeGradient(
  File "/home/xieyi/.local/lib/python3.8/site-packages/tensorflow/python/eager/backprop.py", line 159, in _gradient_function
    return grad_fn(mock_op, *out_grads)
  File "/home/xieyi/.local/lib/python3.8/site-packages/tensorflow/python/ops/nn_grad.py", line 581, in _Conv2DGrad
    gen_nn_ops.conv2d_backprop_input(
  File "/home/xieyi/.local/lib/python3.8/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 1247, in conv2d_backprop_input
    _ops.raise_from_not_ok_status(e, name)
  File "/home/xieyi/.local/lib/python3.8/site-packages/tensorflow/python/framework/ops.py", line 7107, in raise_from_not_ok_status
    raise core._status_to_exception(e) from None  # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: Computed input depth 256 doesn't match filter input depth 64 [Op:Conv2DBackpropInput]
@chunduriv chunduriv self-assigned this Nov 29, 2021
@chunduriv chunduriv added the type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited. label Nov 29, 2021
@chunduriv
Copy link
Collaborator

chunduriv commented Nov 29, 2021

@breadbread1984, Gradients for grouped convolutions are supported on GPU.For more information you can refer this comment. I don't have any issue on Colab using TF_GPU v2.7.0. Please find the gist here. Thanks!

@breadbread1984
Copy link
Author

so the group conv is only available on GPU. thx, problem solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting response from contributor type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited.
Projects
None yet
Development

No branches or pull requests

2 participants