Skip to content

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

Description

@xchoo

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions