tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

transpose operation is removed during conversion with tensorflowjs_converter

Open chenjin3 opened this issue 8 years ago • 8 comments

TensorFlow.js version

tfjs-converter v0.1.2

transpose operation ( between two reshape operations for image scaling ) is missing occasionally

chenjin3 avatar Apr 25 '18 14:04 chenjin3

Hi, can you share more details? Are you converting a SavedModel or a Keras model and can you share code to help us reproduce the issue? Thanks!

dsmilkov avatar Apr 25 '18 14:04 dsmilkov

Hi @chenjin3, can you take a look at issue #85, see if the issue can be solved with the similar approach. It would be very much appreciated if you can ltry it out and let us know, so we could disable the offending grappler optimizers in the short term until it is fixed.

pyu10055 avatar Apr 25 '18 17:04 pyu10055

@dsmilkov I'm converting a SavedModel to Web-friendly format. You can get My SavedModel from this repo. In the debug directory, I print FrozenModel.executor.weightMap to webModel.log file. You can see SR_TV/pixel_s_2/transpose/perm Node, but no SR_TV/pixel_s_1/transpose/perm Node (SR_TV/pixel_s_2 & SR_TV/pixel_s_1 are same operations all include transpose).

chenjin3 avatar Apr 26 '18 02:04 chenjin3

@dsmilkov For supporting resizeBilinear operation, I add following code to src/operations/executors/convolution_executor.js

 case 'resizeBilinear': {
      const alignCorners = getParamValue('alignCorners', node, tensorMap) as boolean;
      const size = getParamValue('size', node, tensorMap) as number[];

      return [tfc.image.resizeBilinear(
        getParamValue('images', node, tensorMap) as tfc.Tensor3D | tfc.Tensor4D,
        [size[0], size[1]],
        alignCorners)];
    }

and

diff --git a/src/operations/executors/convolution_executor.ts b/src/operations/executors/convolution_executor.ts
index cc1950d..cf54c88 100644
--- a/src/operations/executors/convolution_executor.ts
+++ b/src/operations/executors/convolution_executor.ts
@@ -107,7 +107,7 @@ export let executeOp: OpExecutor = (node: Node, tensorMap: NamedTensorsMap):
       const size = getParamValue('size', node, tensorMap) as number[];

       return [tfc.image.resizeBilinear(
-        getParamValue('image', node, tensorMap) as tfc.Tensor3D | tfc.Tensor4D,
+        getParamValue('images', node, tensorMap) as tfc.Tensor3D | tfc.Tensor4D,
         [size[0], size[1]],
         alignCorners)];
     }

chenjin3 avatar Apr 26 '18 03:04 chenjin3

@pyu10055 Do you mean trying change the code in matrices_executor.ts like #85 ?

chenjin3 avatar Apr 26 '18 03:04 chenjin3

@chenjin3 is this fixed by your PR to converter?

pyu10055 avatar May 03 '18 19:05 pyu10055

@pyu10055 Not work. 😕

chenjin3 avatar May 14 '18 01:05 chenjin3

@chenjin3 can you confirm this issue with the latest converter? closing this issue for now, please feel free to reopen if it still does not work. thanks.

pyu10055 avatar Aug 07 '18 21:08 pyu10055