You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "jikechao (via GitHub)" <gi...@apache.org> on 2023/04/24 07:54:13 UTC

[GitHub] [tvm] jikechao commented on a diff in pull request #14707: [Keras][Bugfix] fix a bug about alpha attribute in LeakyReLU which lead to passes conflict

jikechao commented on code in PR #14707:
URL: https://github.com/apache/tvm/pull/14707#discussion_r1174913581


##########
tests/python/frontend/keras/test_forward.py:
##########
@@ -209,6 +211,15 @@ def test_forward_activations(self, keras_mod):
             keras_model = keras_mod.models.Model(data, x)
             verify_keras_frontend(keras_model)
             verify_keras_frontend(keras_model, need_transpose=False, layout="NHWC")
+        # test invalid attribute alpha=None for LeakyReLU
+        if package_version.parse(keras_mod.__version__.split("-tf")[0]) <= package_version.parse(
+            "2.3.1"
+        ):

Review Comment:
   The following model is generated using keras (version 2.2) with the script. However, this model is not a valid model, which should be rejected in TVM front-end checking.  
   ```
   input_shape = (2, 3, 4)
   input_data = np.random.random(input_shape)
   x = layers.Input(shape=input_shape[1:], dtype='float32')
   layer = keras.layers.LeakyReLU(alpha=None)  
   layer.set_weights(layer.get_weights())
   y = layer(x)
   model = models.Model(x, y)
   ```
   
   ![image](https://user-images.githubusercontent.com/29506758/233930829-dcc3774b-c81d-4b3a-9a65-625bbaf87980.png)
   
   However, in the latest keras. Keras found `keras.layers.LeakyReLU(alpha=None)` is not a valid usage and added an exception value checking to avoid generating the invalid model ([see this issue](https://github.com/tensorflow/tensorflow/pull/47017)). Thus, for triggering this crash, we should use keras <=2.3.1.
   



-- 
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