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

TVMError: relay.frontend.from_keras() fails with models compiled in tensorflow 2.3 #6287

Closed
iswariyam opened this issue Aug 15, 2020 · 0 comments · Fixed by #6288
Closed

Comments

@iswariyam
Copy link
Contributor

The following error occurs when feeding a tensorflow 2.3 compiled model to relay.frontend.from_keras()

AttributeError: 'Node' object has no attribute 'node_indices'

The following code can be used to reproduce the error.

import numpy as np
import tensorflow as tf
import tensorflow.keras as keras
from matplotlib import pyplot as plt
from PIL import Image
from tensorflow.keras.applications.resnet50 import preprocess_input

import tvm
import tvm.relay as relay
from tvm import te
from tvm.contrib.download import download_testdata

keras_resnet50 = keras.applications.resnet50.ResNet50(
    include_top=True, input_shape=(224, 224, 3), classes=1000
)

img_url = "https://github.com/dmlc/mxnet.js/blob/master/data/cat.png?raw=true"
img_path = download_testdata(img_url, "cat.png", module="data")
img = Image.open(img_path).resize((224, 224))

# input preprocess
data = np.array(img)[np.newaxis, :].astype("float32")
data = preprocess_input(data).transpose([0, 3, 1, 2])
print("input_1", data.shape)

shape_dict = {"input_1": data.shape}
mod, params = relay.frontend.from_keras(keras_resnet50, shape_dict)

Reason

The issue occurs due to changes in the attributes of the Node class in tensorflow 2.3 as compared to tensorflow 2.2

Environment:

  • Python : 3.7.7
  • Tensorflow : 2.3
  • TVM : 0.7.dev1
  • OS : Ubuntu 16.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant