0

我目前正在尝试使用 tensorflow 模型优化模块对对象检测模型进行量化感知训练。我在尝试执行此操作时不断收到错误,并在下面附上了我的代码和错误。每当我尝试使用 quantize_model 时,都会弹出此错误:“ValueError: Cannot assign to variableefficientnet-lite4/blocks_0/depthwise_conv2d/depthwise_kernel:0 due to variable shape (3, 3, 32, 1) and value shape (3, 3) , 224, 1) 不兼容”。我该如何解决这个问题,或者是否有更简单的方法来量化感知训练对象检测模型以在谷歌珊瑚 USB 加速器上工作?

import tensorflow as tf
import os
import numpy as np
import tensorflow_hub as hub
import cv2
import tensorflow_model_optimization as tfmot

quantize_scope = tfmot.quantization.keras.quantize_scope
quantize_model = tfmot.quantization.keras.quantize_model

class CustomLayer(hub.KerasLayer):
    pass

inputs = tf.keras.Input(shape=(512, 512, 3), name="img")
outputs = CustomLayer("https://tfhub.dev/tensorflow/efficientdet/lite4/feature-vector/1")(inputs)
model = tf.keras.Model(inputs, outputs, name="JPLDetector")

with quantize_scope({"CustomLayer":CustomLayer}):
    model = quantize_model(model)
model.summary()

错误: 错误图像

4

0 回答 0