Tfjs: Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D

Created on 13 Jul 2019  Â·  7Comments  Â·  Source: tensorflow/tfjs

To get help from the community, we encourage using Stack Overflow and the tensorflow.js tag.

TensorFlow.js version

1.2.3

Browser version

Node 10.15

Describe the problem or feature request

When loading in a converted layer model, I get the following error message:
Error: Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.
The model was a variation of Xception. It contains many SeparableConv2D layer and a few of them uses kernal_initializer. It appeared that the tfjs version think those fields are invalid.

Code to reproduce the bug / link to feature request

  1. You can reproduce by saving the Xception application model into a h5 keras model using model.save.
  2. Convert the model into tfjs_layer_models as describe by tensorflowjs_converter website
  3. Load it back in using tfjs
    const tf = require("@tensorflow/tfjs"); const tfn = require("@tensorflow/tfjs-node"); const handler = tfn.io.fileSystem("./layer_model/model.json"); const model = await tf.loadLayersModel(handler);
converter bug

Most helpful comment

The underlying implementation of Xception is directly from tf.keras.applications with no change to any ContNet. If the use of the attributes are invalid, then the Xception implementation in tf.keras should be fixed as well.

All 7 comments

Until this is resolved, I found a temporary work around.

  1. Save the model in your python code as tensorflow graph
    print(model.outputs) tf.saved_model.simple_save( sess, export_path, inputs={'input_image': model.input}, outputs={t.name: t for t inmodel.outputs})`
  2. Use tensorflowjs==0.8.6 (must be this version for py3 and tf==1.12) to convert the graph model for tensorflow
    tensorflowjs_converter \ --input_format=tf_saved_model \ --output_format=tensorflowjs \ --output_node_names="predictions/BiasAdd:0" \ --saved_model_tags=serve \ src \ dest
    (you can find the output_node_names by print(model.outputs) from original python model

It appears that the fields are technically invalid for python Keras as well:
https://github.com/keras-team/keras/blob/master/keras/layers/convolutional.py#L1546

Probably what's happening here is that those fields are invalid, but the Python implementation is more permissive.

Proposed solution:
@pyu10055 should we add an option to the converter warn and strip invalid configurations rather than fail on load after conversion?

The underlying implementation of Xception is directly from tf.keras.applications with no change to any ContNet. If the use of the attributes are invalid, then the Xception implementation in tf.keras should be fixed as well.

+1

On Mon, Jul 22, 2019 at 11:02 AM Jerry Deng notifications@github.com
wrote:

The underlying implementation of Xception is directly from
tf.keras.applications with no change to any ContNet. If the use of the
attributes are invalid, then the Xception implementation in tf.keras should
be fixed as well.

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/tensorflow/tfjs/issues/1739?email_source=notifications&email_token=AAEFSTSSJU6NHAWE6GNJKT3QAXD2FA5CNFSM4ICSFLF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2QGZSI#issuecomment-513830089,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEFSTSWANUTJNKA4RC5KALQAXD2FANCNFSM4ICSFLFQ
.

Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!

Should this be closed? This is still an issue now. Is there an update on the progress of this bug?

maybe this answer about the use of the layers model and graph model clarifies the priority for this issue: https://stackoverflow.com/a/63621486/3866264

Was this page helpful?
0 / 5 - 0 ratings