【发布时间】:2021-04-16 02:14:27
【问题描述】:
我想在设备上使用 Google BigTransfer 论文中的模型。
纸张: https://arxiv.org/abs/1912.11370
代码: https://github.com/google-research/big_transfer/blob/master/colabs/big_transfer_tf2.ipynb
这是我的 TF Lite 代码:
def representative_data_gen():
for x, _ in validation_ds.take(QUANTIZATION_REPRESENTATIVE_DATASET_SIZE):
yield [x]
converter = tf.lite.TFLiteConverter.from_saved_model(MODEL_DIR)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.representative_dataset = representative_data_gen
tflite_model = converter.convert()
这是我得到的错误:
<unknown>:0: error: failed while converting: 'main': Ops that can be supported by the flex runtime (enabled via setting the -emit-select-tf-ops flag):
tf.SquaredDifference {device = ""}
看起来 Tensorflow Lite 无法执行 group_norm,因为 tf.SquaredDifference 没有操作。关于如何将 Google 的 BiT 模型转换为 Tensorflow Lite 的任何想法?
【问题讨论】:
-
试试TF select ops 但在这种情况下你不能使用量化。而且模型转换的可能性不是 100%。
标签: tensorflow tensorflow-lite quantization