{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/35678","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/35678/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/35678/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/35678/events","html_url":"https://github.com/tensorflow/tensorflow/issues/35678","id":546940678,"node_id":"MDU6SXNzdWU1NDY5NDA2Nzg=","number":35678,"title":"TensorFlowLite_LSTM_Keras_Tutorial.ipynb update ","user":{"login":"AlexVaith","id":57894920,"node_id":"MDQ6VXNlcjU3ODk0OTIw","avatar_url":"https://avatars2.githubusercontent.com/u/57894920?v=4","gravatar_id":"","url":"https://api.github.com/users/AlexVaith","html_url":"https://github.com/AlexVaith","followers_url":"https://api.github.com/users/AlexVaith/followers","following_url":"https://api.github.com/users/AlexVaith/following{/other_user}","gists_url":"https://api.github.com/users/AlexVaith/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexVaith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexVaith/subscriptions","organizations_url":"https://api.github.com/users/AlexVaith/orgs","repos_url":"https://api.github.com/users/AlexVaith/repos","events_url":"https://api.github.com/users/AlexVaith/events{/privacy}","received_events_url":"https://api.github.com/users/AlexVaith/received_events","type":"User","site_admin":false},"labels":[{"id":1605791310,"node_id":"MDU6TGFiZWwxNjA1NzkxMzEw","url":"https://api.github.com/repos/tensorflow/tensorflow/labels/TF%202.1","name":"TF 2.1","color":"c2e0c6","default":false,"description":"for tracking issues in 2.1 release"},{"id":750616506,"node_id":"MDU6TGFiZWw3NTA2MTY1MDY=","url":"https://api.github.com/repos/tensorflow/tensorflow/labels/comp:lite","name":"comp:lite","color":"0052cc","default":false,"description":""},{"id":386191887,"node_id":"MDU6TGFiZWwzODYxOTE4ODc=","url":"https://api.github.com/repos/tensorflow/tensorflow/labels/stat:awaiting%20response","name":"stat:awaiting response","color":"f4b400","default":false,"description":""},{"id":284443156,"node_id":"MDU6TGFiZWwyODQ0NDMxNTY=","url":"https://api.github.com/repos/tensorflow/tensorflow/labels/type:docs","name":"type:docs","color":"159b2e","default":false,"description":""}],"state":"open","locked":false,"assignee":{"login":"jvishnuvardhan","id":46058173,"node_id":"MDQ6VXNlcjQ2MDU4MTcz","avatar_url":"https://avatars2.githubusercontent.com/u/46058173?v=4","gravatar_id":"","url":"https://api.github.com/users/jvishnuvardhan","html_url":"https://github.com/jvishnuvardhan","followers_url":"https://api.github.com/users/jvishnuvardhan/followers","following_url":"https://api.github.com/users/jvishnuvardhan/following{/other_user}","gists_url":"https://api.github.com/users/jvishnuvardhan/gists{/gist_id}","starred_url":"https://api.github.com/users/jvishnuvardhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvishnuvardhan/subscriptions","organizations_url":"https://api.github.com/users/jvishnuvardhan/orgs","repos_url":"https://api.github.com/users/jvishnuvardhan/repos","events_url":"https://api.github.com/users/jvishnuvardhan/events{/privacy}","received_events_url":"https://api.github.com/users/jvishnuvardhan/received_events","type":"User","site_admin":false},"assignees":[{"login":"jvishnuvardhan","id":46058173,"node_id":"MDQ6VXNlcjQ2MDU4MTcz","avatar_url":"https://avatars2.githubusercontent.com/u/46058173?v=4","gravatar_id":"","url":"https://api.github.com/users/jvishnuvardhan","html_url":"https://github.com/jvishnuvardhan","followers_url":"https://api.github.com/users/jvishnuvardhan/followers","following_url":"https://api.github.com/users/jvishnuvardhan/following{/other_user}","gists_url":"https://api.github.com/users/jvishnuvardhan/gists{/gist_id}","starred_url":"https://api.github.com/users/jvishnuvardhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvishnuvardhan/subscriptions","organizations_url":"https://api.github.com/users/jvishnuvardhan/orgs","repos_url":"https://api.github.com/users/jvishnuvardhan/repos","events_url":"https://api.github.com/users/jvishnuvardhan/events{/privacy}","received_events_url":"https://api.github.com/users/jvishnuvardhan/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2020-01-08T15:41:15Z","updated_at":"2020-01-10T08:34:29Z","closed_at":null,"author_association":"NONE","body":"Thank you for submitting a TensorFlow documentation issue. Per our GitHub\r\npolicy, we only address code/doc bugs, performance issues, feature requests, and\r\nbuild/installation issues on GitHub.\r\n\r\nThe TensorFlow docs are open source! To get involved, read the documentation\r\ncontributor guide: https://www.tensorflow.org/community/contribute/docs\r\n\r\n## URL(s) with the issue:\r\n\r\nPlease provide a link to the documentation entry, for example:\r\nhttps://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/experimental/examples/lstm/TensorFlowLite_LSTM_Keras_Tutorial.ipynb\r\n\r\n## Description of issue (what needs changing):\r\nThe example script on how to make lstm layers ready for tf lite is outdated and not working anymore, because the requested tf-nightly package causes issues. \r\n\r\n\r\nI would like to get an updated tutorial or a better alternative. To use the TFLite converter with the experimental_flag set to True works with lstm layers, but does not allow post training quantization. As a general question I would like to know, if this would be possible with the the model that is build in the example script?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/572929142","html_url":"https://github.com/tensorflow/tensorflow/issues/35678#issuecomment-572929142","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/35678","id":572929142,"node_id":"MDEyOklzc3VlQ29tbWVudDU3MjkyOTE0Mg==","user":{"login":"AlexVaith","id":57894920,"node_id":"MDQ6VXNlcjU3ODk0OTIw","avatar_url":"https://avatars2.githubusercontent.com/u/57894920?v=4","gravatar_id":"","url":"https://api.github.com/users/AlexVaith","html_url":"https://github.com/AlexVaith","followers_url":"https://api.github.com/users/AlexVaith/followers","following_url":"https://api.github.com/users/AlexVaith/following{/other_user}","gists_url":"https://api.github.com/users/AlexVaith/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexVaith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexVaith/subscriptions","organizations_url":"https://api.github.com/users/AlexVaith/orgs","repos_url":"https://api.github.com/users/AlexVaith/repos","events_url":"https://api.github.com/users/AlexVaith/events{/privacy}","received_events_url":"https://api.github.com/users/AlexVaith/received_events","type":"User","site_admin":false},"created_at":"2020-01-10T08:34:28Z","updated_at":"2020-01-10T08:34:28Z","author_association":"NONE","body":"@jvishnuvardhan I tried this link with an lstm model looking like the following:\r\n\r\n```\r\ndef build_model_tf(lr, window_size, features, classes):\r\n    # input layer\r\n    inp = tf.keras.layers.Input(shape=[window_size, features], batch_size=42)\r\n    # batch norm layer to normalize data\r\n    x = tf.keras.layers.BatchNormalization()(inp)\r\n\r\n    # two convolutional layers\r\n    x = tf.keras.layers.Conv1D(filters=16, kernel_size=3)(x)\r\n    x = tf.keras.layers.Activation('relu')(x)\r\n    x = tf.keras.layers.BatchNormalization()(x)\r\n\r\n    x = tf.keras.layers.Conv1D(filters=32, kernel_size=6)(x)\r\n    x = tf.keras.layers.Activation('relu')(x)\r\n    x = tf.keras.layers.BatchNormalization()(x)\r\n\r\n    # 3 lstm layers\r\n    x = tf.keras.layers.LSTM(32, return_sequences=True, recurrent_regularizer=tf.keras.regularizers.L1L2(0.5, 0.1))(x)\r\n    x = tf.keras.layers.LSTM(24, return_sequences=True, recurrent_regularizer=tf.keras.regularizers.L1L2(0.5, 0.1))(x)\r\n    x = tf.keras.layers.LSTM(16, return_sequences=False, recurrent_regularizer=tf.keras.regularizers.L1L2(0.5, 0.1))(x)\r\n\r\n    # dense layer\r\n    x = tf.keras.layers.Dense(8)(x)\r\n    x = tf.keras.layers.Activation('relu')(x)\r\n    x = tf.keras.layers.Dropout(0.35)(x)\r\n    #\r\n    # output layer\r\n    out = tf.keras.layers.Dense(classes, activation='softmax')(x)\r\n\r\n    # create functional model object\r\n    model = tf.keras.models.Model(inputs=inp, outputs=out)\r\n\r\n    model.compile(optimizer=tf.keras.optimizers.Adam(lr=lr, decay=1e-5), loss='categorical_crossentropy', metrics=['accuracy'])\r\n\r\n    return model\r\n```\r\n\r\nit was than converted like this:\r\n```\r\n# convert keras model to concrete functions\r\ntf.saved_model.save(tf_keras_model, join(ROOT, 'trained_models', model_name + '_conv'))\r\nmodel = tf.saved_model.load(join(ROOT, 'trained_models', model_name + '_conv'))\r\nconcrete_func = model.signatures[\r\n  tf.saved_model.DEFAULT_SERVING_SIGNATURE_DEF_KEY]\r\n# initialize the tf_light converter\r\nconverter = tf.lite.TFLiteConverter.from_concrete_functions([concrete_func])\r\nconverter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]\r\n# add experimental flag, because rnn structures are not covered by the default converter\r\nconverter.experimental_new_converter = True\r\n# convert model to tf_light\r\ntf_lite_model = converter.convert()\r\n```\r\nWithout the following line it works:\r\n```\r\nconverter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]\r\n```\r\nBut with this line the same issue like in the following post occurs:\r\nhttps://github.com/tensorflow/tensorflow/issues/35194\r\n\r\nI am using tensorflow 2.0.0 and tf nightly."}}
{"actor":{"display_login":"AlexVaith"}}