You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "haoyang9804 (via GitHub)" <gi...@apache.org> on 2023/07/08 07:23:04 UTC
[GitHub] [tvm] haoyang9804 opened a new pull request, #15265: Fix keras version problem
haoyang9804 opened a new pull request, #15265:
URL: https://github.com/apache/tvm/pull/15265
I met this problem when I try to fix this [issue](https://github.com/apache/tvm/issues/15160), and here is the bug-triggered script:
```Python
import tvm
import tvm.relay as relay
import numpy as np
from tensorflow import keras
from tensorflow.keras import layers, models
input_shape = (1, 5, 7, 6, 2)
input_data = np.random.random(size=input_shape)
x = layers.Input(shape=input_shape[1:], dtype='float64')
layer = keras.layers.Conv3D(filters=1, kernel_size=3)
layer.set_weights(layer.get_weights())
y = layer(x)
model = models.Model(x, y)
model.summary()
res_keras = model(input_data)
shape_dict = {'input_1': input_shape}
mod, params = relay.frontend.from_keras(model, shape_dict,layout='NDHWC')
with tvm.transform.PassContext(opt_level=3):
model = relay.build_module.create_executor("graph", mod, tvm.cpu(0), 'llvm', params).evaluate()
test_x_tvm = input_data
res_tvm = model(tvm.nd.array(test_x_tvm.astype('float64'))).numpy()
```
`relay.frontend.from_keras` invokes the following error:
```
Traceback (most recent call last):
File "/Users/mahaoyang/repo/tests/python/test.py", line 21, in <module>
mod, params = relay.frontend.from_keras(model, shape_dict,layout='NDHWC')
File "/Users/mahaoyang/repo/tvm/python/tvm/relay/frontend/keras.py", line 1530, in from_keras
import keras.engine as E
ModuleNotFoundError: No module named 'keras.engine
```
The reason for this error is that `keras.engine` has been changed into `keras.src.engine` in my installed tensorflow(2.13.0), in which keras's version is 2.13.1.
So I add a `if` to judge the version of keras and fix this compatibility issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] tvm-bot commented on pull request #15265: Fix keras version problem
Posted by "tvm-bot (via GitHub)" <gi...@apache.org>.
tvm-bot commented on PR #15265:
URL: https://github.com/apache/tvm/pull/15265#issuecomment-1626894541
<!---bot-comment-->
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
<!--bot-comment-ccs-start-->
* No users to auto-tag found, no teams are specified in PR title <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
<sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] haoyang9804 commented on pull request #15265: Fix keras version problem
Posted by "haoyang9804 (via GitHub)" <gi...@apache.org>.
haoyang9804 commented on PR #15265:
URL: https://github.com/apache/tvm/pull/15265#issuecomment-1626895151
@echuraev
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] jikechao commented on pull request #15265: Fix keras version problem
Posted by "jikechao (via GitHub)" <gi...@apache.org>.
jikechao commented on PR #15265:
URL: https://github.com/apache/tvm/pull/15265#issuecomment-1635643571
Thank you for the fix. LGTM!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] echuraev merged pull request #15265: Fix keras version problem
Posted by "echuraev (via GitHub)" <gi...@apache.org>.
echuraev merged PR #15265:
URL: https://github.com/apache/tvm/pull/15265
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org