tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

Error: FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias

Open okyanusoz opened this issue 3 years ago • 5 comments

I keep getting Error: FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias. when I try model.predict() on a MobileNet model.

The model looks like this in Python (Kaggle notebooks):

layer = hub.KerasLayer("https://tfhub.dev/google/imagenet/mobilenet_v3_large_100_224/feature_vector/5",
           trainable=False, input_shape=(224, 224, 3))
model = tf.keras.Sequential([
  normalization_layer,
  layer,
  tf.keras.layers.Dense(len(class_names), activation="softmax")
])
model.compile(
  optimizer=tf.keras.optimizers.Adam(),
  loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
  metrics=['acc'])

history = model.fit(train_ds,
                validation_data=val_ds,
                epochs=2)
model.save("model")

The converter command (another notebook):

tensorflowjs_converter \
--input_format=tf_saved_model \
--output_format=tfjs_graph_model \
--signature_name=serving_default \
--saved_model_tags=serve \
[model path] \
web_model

The JS code (my machine) :

const model = await tf.loadGraphModel("file://" + __dirname + "/web_model/model.json") console.log(new Array(...(await modelPromise).predict(tf.node.decodeImage(blob).resizeBilinear([224,224]).expandDims(0)).dataSync()))

Stack trace:

Error: FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.
at fusedConvAndDepthWiseParams (/Users/stackoverflow/Desktop/jsmodel/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:27747:19)
at executeOp$g (/Users/stackoverflow/Desktop/jsmodel/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:27795:22)
at /Users/stackoverflow/Desktop/jsmodel/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:28975:65
at /Users/stackoverflow/Desktop/jsmodel/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4441:22
at Engine.scopedRun (/Users/stackoverflow/Desktop/jsmodel/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4451:23)
at Engine.tidy (/Users/stackoverflow/Desktop/jsmodel/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4440:21)
at Object.tidy (/Users/stackoverflow/Desktop/jsmodel/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:8901:19)
at /Users/stackoverflow/Desktop/jsmodel/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:28975:39
at executeOp (/Users/stackoverflow/Desktop/jsmodel/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:29019:7)
at /Users/stackoverflow/Desktop/jsmodel/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:29513:35

okyanusoz avatar Jun 10 '22 11:06 okyanusoz

@okyanusoz did you get chance to check the related issue here https://github.com/tensorflow/tfjs/issues/5013 , could you please share the version of tfjs and python ?

rthadur avatar Jun 14 '22 18:06 rthadur

Yes, I did. I tried updating TensorFlow.js, but to no avail. Here's my environment:

The training notebook: Python 3.7.12 TensorFlow 2.6.4

The JS conversion notebook: Python 3.7.12 TensorFlow 2.6.4 TensorFlow.js converter (tensorflowjs) 3.18.0

JS code (my machine): TensorFlow.js (tfjs-node) 3.18.0 Node.js 14.17.1

okyanusoz avatar Jun 15 '22 09:06 okyanusoz

When I use another model like PNasNet, this doesn't happen.

okyanusoz avatar Jun 15 '22 09:06 okyanusoz

@okyanusoz Can you share the saved model? I can't run your code to generate the model since you didn't provide all the values

ahmedsabie avatar Sep 07 '22 18:09 ahmedsabie

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you.

google-ml-butler[bot] avatar Sep 16 '22 20:09 google-ml-butler[bot]

Closing as stale. Please @mention us if this needs more attention.

google-ml-butler[bot] avatar Sep 23 '22 20:09 google-ml-butler[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Sep 23 '22 20:09 google-ml-butler[bot]