float16 quantization runs out of memory for LSTM model
@yyoon がすでに取り組んでいます。
2023年8月31日 から。
評価
この issue はまだ評価されていません。
説明
No matter the size of the LSTM model, converting it with float16 optimization runs out of memory.
Code to reproduce the issue
The code snippet to reproduce the issue on Google Colab
Code:
import numpy as np
import tensorflow as tf
import tensorflow_model_optimization as tfmot
def create_model():
model = tf.keras.models.Sequential()
# For the model to later get converted, batch_size and sequence_length should be fixed.
# E.g., batch_input_shape=[None, 1] will throw an error.
# This is just a limitation when using RNNs. E.g., for FC or CNN we can have batch_size=None
model.add(tf.keras.layers.Embedding(
input_dim=5,
output_dim=1,
batch_input_shape=[1, 1]
))
model.add(tf.keras.layers.LSTM(
units=1,
return_sequences=False,
stateful=False
))
model.add(tf.keras.layers.Dense(5))
return model
model = create_model()
model.summary()
model.save("/content/model/")
representative_data = np.random.randint(0, 5, (200, 1)).astype(np.float32)
def representative_dataset():
for sample in representative_data:
sample = np.expand_dims(sample, axis=0) # batch_size = 1
yield [sample] # set sample as first (and only) input of the model
# float16 quantization
converter = tf.lite.TFLiteConverter.from_saved_model("/content/model/")
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_types = [tf.float16]
# kernel runs out of memory and crashes in the following line
tflite_quant_model = converter.convert()
- 主要言語
- Python
- スター
- 1.6k
- フォーク
- 348
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tensorflow/model-optimization のほかの issue
-
Broken pre-optimized models link in getting-started guide対応中かも @itzzdev09 が 25 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
tensorflow/model-optimization#1301 · コメント 1 件 ·
-
tensorflow-model-optimization fails to import in official tensorflow:2.15.0 Docker image due to TF_USE_LEGACY_KERAS=1 and missing tf_keras対応中かも @JiwaniZakir が 176 日前に担当しました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
tensorflow/model-optimization#1272 ·
-
quantize_model() rejects a valid standalone Keras 3 Sequential model再び着手できるかも @MoeenAsim が 75 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
tensorflow/model-optimization#1270 · コメント 2 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 48/100
tensorflow/model-optimization#1241 ·
-
First Conv2D layer in model cannot be pruned with structured sparsity (sparsity_m_by_n)再び着手できるかも @shoaib-niazi が 289 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
tensorflow/model-optimization#1182 · コメント 1 件 ·
tensorflow/model-optimization の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
lugassawan/swe-workbench#799 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
vllm-project/vllm#61131 ·
メンテナーはふだん 1 日以内に返信
-
Non-string form field names raise AttributeError when files are attached対応中かも @nightcityblade が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
kubernetes-client/python#2735 ·
メンテナーはふだん 1 日以内に返信
-
desktop help wanted test
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信