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

Converter fails with tf.keras.applications.EfficientNet #217

Open
xchoo opened this issue Sep 13, 2021 · 0 comments
Open

Converter fails with tf.keras.applications.EfficientNet #217

xchoo opened this issue Sep 13, 2021 · 0 comments

Comments

@xchoo
Copy link
Member

xchoo commented Sep 13, 2021

Trying to use the NengoDL converter with the built-in EfficientNet TensorFlow networks will cause a failure with this error:

:\xchoo\git\nengo-dl\nengo_dl\converter.py:324: UserWarning: Layer type Rescaling does not have a registered converter. Falling back to TensorNode.
  warnings.warn(
d:\xchoo\git\nengo-dl\nengo_dl\converter.py:324: UserWarning: Layer type Normalization does not have a registered converter. Falling back to TensorNode.
  warnings.warn(
d:\xchoo\git\nengo-dl\nengo_dl\converter.py:586: UserWarning: Activation type <function swish at 0x0000017DD4D479D0> does not have a native Nengo equivalent; falling back to a TensorNode
  warnings.warn(
d:\xchoo\git\nengo-dl\nengo_dl\converter.py:324: UserWarning: Layer type DepthwiseConv2D does not have a registered converter. Falling back to TensorNode.
  warnings.warn(
d:\xchoo\git\nengo-dl\nengo_dl\converter.py:324: UserWarning: Layer type Multiply does not have a registered converter. Falling back to TensorNode.
  warnings.warn(
Traceback (most recent call last):
  File ".\test_efficientnet.py", line 59, in <module>
    conv = nengo_dl.Converter(
  File "d:\xchoo\git\nengo-dl\nengo_dl\converter.py", line 133, in __init__
    self.net = self.get_converter(model).convert(None)
  File "d:\xchoo\git\nengo-dl\nengo_dl\converter.py", line 870, in convert
    nengo_layer = layer_converter.convert(layer_node_id)
  File "d:\xchoo\git\nengo-dl\nengo_dl\converter.py", line 962, in convert
    output = self.tensor_layer(
  File "d:\xchoo\git\nengo-dl\nengo_dl\tensor_node.py", line 458, in __call__
    obj = TensorNode(
  File "D:\xchoo\miniconda3\envs\nengo-dl\lib\site-packages\nengo\base.py", line 34, in __call__
    inst.__init__(*args, **kwargs)
  File "d:\xchoo\git\nengo-dl\nengo_dl\tensor_node.py", line 198, in __init__
    self.shape_in = shape_in
  File "D:\xchoo\miniconda3\envs\nengo-dl\lib\site-packages\nengo\base.py", line 108, in __setattr__
    super().__setattr__(name, val)
  File "D:\xchoo\miniconda3\envs\nengo-dl\lib\site-packages\nengo\config.py", line 484, in __setattr__
    raise exc_info[1].with_traceback(None) from e
nengo.exceptions.ValidationError: TensorNode.shape_in: Element 0 must be an int (got type 'tuple')

Minimal code to reproduce error:

import nengo_dl
import tensorflow as tf

model = tf.keras.applications.EfficientNetB2(
    include_top=True,
    weights="imagenet",
    input_tensor=None,
    input_shape=None,
    pooling=None,
    classes=1000,
    classifier_activation="softmax",
)

conv = nengo_dl.Converter(
    model, allow_fallback=True, max_to_avg_pool=True, inference_only=True
)

I tested some of the other tf.keras.applications networks, and the only networks that seem to be affected are the EfficientNet ones.

First reported on the Nengo forums here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant