小编Ale*_*der的帖子

使用 TFLiteConverter 将 Keras 模型转换为量化的 tflite 版本导致 NOTYPE 错误

在转换和执行 keras 模型的 8 位量化时,我遇到了图像数据集没有发生的奇怪错误。

import tensorflow.python.keras.backend as K
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.models import load_model
import numpy as np

x_train = np.array([[0.6171875  0.59791666],[0.6171875  0.59791666],[0.6171875  0.59791666]])
y_train = np.array([[0.6171875  0.59791666],[0.6171875  0.59791666],[0.6171875  0.59791666]])


def representative_dataset_gen():
    for i in range(1):
        # Get sample input data as a numpy array in a method of your choosing.
        sample = np.array([0.5,0.6])
        sample = np.expand_dims(sample, axis=0)
        yield [sample]



model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(2,)),
  tf.keras.layers.Dense(12, activation='relu'),
  tf.keras.layers.Dense(2, activation='softmax')
])


model.compile(optimizer='adam',
              loss='categorical_crossentropy',
              metrics=['accuracy'])

model.fit(x_train, …
Run Code Online (Sandbox Code Playgroud)

quantization keras tensorflow tensorflow-lite google-coral

2
推荐指数
1
解决办法
611
查看次数