Skip to content

tfjs converter supported tf.keras.layers.Conv2DTranspose ? #8148

@kaka-lin

Description

@kaka-lin

Please make sure that this is a bug. As per our
GitHub Policy,
we only address code/doc bugs, performance issues, feature requests and
build/installation issues on GitHub. tag:bug_template

System information

  • Have I written custom code: No
  • OS Platform and Distribution: MacOS
  • TensorFlow.js installed from (npm or script link): npm
  • TensorFlow.js version (use command below): 4.16.0
  • Tensorflow.js Converter Version: 4.16.0

Describe the current behavior

My model has a layer as below:

tf.keras.layers.Conv2DTranspose(
    self.hidden_size // 4, kernel_size=2, strides=2, name="0.0", data_format="channels_first")

I converted this model to tfjs format and ran it, encountered an error as below:

util_base.ts:153 Uncaught (in promise) Error: Error in conv2dDerInput: depth of input (128) must match input depth for filter 64.
    at Module.assert (util_base.ts:153:1)
    at conv2DBackpropInput_ (conv2d_backprop_input.ts:87:1)
    at conv2DBackpropInput__op (operation.ts:51:1)
    at conv2dTranspose_ (conv2d_transpose.ts:54:1)
    at Module.conv2dTranspose__op (operation.ts:51:1)
    at Module.executeOp (convolution_executor.ts:183:1)
    at operation_executor.ts:69:1
    at engine.ts:469:1
    at Engine.scopedRun (engine.ts:480:1)
    at Engine.tidy (engine.ts:467:1)

And then when I edit conv2d_transpose.js

return conv2DBackpropInput(outputShape, $x, $filter, strides, pad, 'NHWC', dimRoundingMode);

to

return conv2DBackpropInput(outputShape, $x, $filter, strides, pad, 'NCHW', dimRoundingMode);

then occur an error like below:

截圖 2024-01-19 下午12 53 31

Describe the expected behavior

Should be run without any error.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions