payload: {"action":"opened","issue":{"url":"https://api.github.com/repos/HawkAaron/warp-transducer/issues/51","repository_url":"https://api.github.com/repos/HawkAaron/warp-transducer","labels_url":"https://api.github.com/repos/HawkAaron/warp-transducer/issues/51/labels{/name}","comments_url":"https://api.github.com/repos/HawkAaron/warp-transducer/issues/51/comments","events_url":"https://api.github.com/repos/HawkAaron/warp-transducer/issues/51/events","html_url":"https://github.com/HawkAaron/warp-transducer/issues/51","id":499882123,"node_id":"MDU6SXNzdWU0OTk4ODIxMjM=","number":51,"title":"Adding rnnt_loss to Keras (\"Cannot iterate over a shape with unknown rank.\")","user":{"login":"sephiroce","id":661463,"node_id":"MDQ6VXNlcjY2MTQ2Mw==","avatar_url":"https://avatars2.githubusercontent.com/u/661463?v=4","gravatar_id":"","url":"https://api.github.com/users/sephiroce","html_url":"https://github.com/sephiroce","followers_url":"https://api.github.com/users/sephiroce/followers","following_url":"https://api.github.com/users/sephiroce/following{/other_user}","gists_url":"https://api.github.com/users/sephiroce/gists{/gist_id}","starred_url":"https://api.github.com/users/sephiroce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sephiroce/subscriptions","organizations_url":"https://api.github.com/users/sephiroce/orgs","repos_url":"https://api.github.com/users/sephiroce/repos","events_url":"https://api.github.com/users/sephiroce/events{/privacy}","received_events_url":"https://api.github.com/users/sephiroce/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-09-29T08:51:17Z","updated_at":"2019-09-29T08:51:17Z","closed_at":null,"author_association":"NONE","body":"I'm trying to build up an rnn-t baseline system using Keras.\r\nThe rnn-t model can not be compiled with the error message below.\r\n```\r\nValueError: Cannot iterate over a shape with unknown rank.\r\n```\r\n\r\nPlease check the lambda function.\r\n```\r\n  def rnnt_lambda_func(args):\r\n    # y_trans: the output of transcription networks\r\n    # y_pred: the output of prediction networks\r\n    # labels; true sequence\r\n    y_trans, y_pred, labels, input_length, label_length = args\r\n    import keras.backend as K\r\n\r\n    # calculating lattices from the output from the prediction network and the transcription network.\r\n    B = K.shape(y_trans)[0]\r\n    T = K.shape(y_trans)[1]\r\n    U = K.shape(y_pred)[1]\r\n    V = K.shape(y_trans)[2]\r\n\r\n    y_trans = K.reshape(K.tile(y_trans, [1, U, 1]), [B, T, U, V])\r\n    y_pred = K.reshape(K.tile(y_pred, [1, T, 1]), [B, T, U, V])\r\n\r\n    logit_lattice = K.exp(y_trans + y_pred)\r\n    acts = K.softmax(logit_lattice, axis=3)\r\n\r\n    from warprnnt_tensorflow import rnnt_loss\r\n    return rnnt_loss(acts, K.cast(labels, 'int32'),\r\n                                     K.cast(input_length, 'int32'),\r\n                                     K.cast(label_length, 'int32'), 29)\r\n```\r\n\r\nThis is the source code for adding a lambda layer to the model.\r\n```\r\n# y_trans: the output of transcription networks\r\n# y_pred: the output of prediction networks\r\n# labels; true sequence\r\n    loss_out = Lambda(Util.rnnt_lambda_func, output_shape=(1,),\r\n                      name=Constants.KEY_RNTLS)([y_trans, y_pred, labels, input_length, label_length])\r\n    model = Model(inputs=[input_data] + [labels, input_length, label_length],\r\n                             outputs=loss_out)\r\n    optimizer = SGD(lr=lr, decay=lr * 0.0001, momentum=0.9, nesterov=True,\r\n                    clipnorm=5)\r\n    model.compile(loss={Constants.KEY_RNTLS: lambda y_true, y_pred: y_pred[0]},\r\n               optimizer=optimizer)\r\n```\r\n\r\n\r\n"}}
other: {"actor":{"display_login":"sephiroce"}}