节点 quant_conv1/cond/LastValueQuant/AssignMinLast 的输入 0 从 quant_conv1/cond/LastValueQuant/AssignMinLast/Switch:1 incompatib 传入浮点数

问题描述

TF 版本 - 1.15

我在 SSD 模型的卷积层上应用了量化。 Link

这是我做的

  1. 训练模型并保存模型。 我的模型 model.summary() 看起来像这样
Model: "model"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_1 (InputLayer)            [(None,300,480,3) 0                                            
__________________________________________________________________________________________________
identity_layer (Lambda)         (None,3)  0           input_1[0][0]                    
__________________________________________________________________________________________________
input_mean_normalization (Lambd (None,3)  0           identity_layer[0][0]             
__________________________________________________________________________________________________
input_stddev_normalization (Lam (None,3)  0           input_mean_normalization[0][0]   
__________________________________________________________________________________________________
conv1 (Conv2D)                  (None,32) 2432        input_stddev_normalization[0][0] 
__________________________________________________________________________________________________
bn1 (Batchnormalization)        (None,32) 128         conv1[0][0]                      
__________________________________________________________________________________________________
elu1 (ELU)                      (None,32) 0           bn1[0][0]                        
__________________________________________________________________________________________________
pool1 (MaxPooling2D)            (None,150,240,32) 0           elu1[0][0]                       
__________________________________________________________________________________________________
conv2 (Conv2D)                  (None,48) 13872       pool1[0][0]                      
__________________________________________________________________________________________________
bn2 (Batchnormalization)        (None,48) 192         conv2[0][0]                      
__________________________________________________________________________________________________
elu2 (ELU)                      (None,48) 0           bn2[0][0]                        
__________________________________________________________________________________________________
pool2 (MaxPooling2D)            (None,75,120,48)  0           elu2[0][0]                       
__________________________________________________________________________________________________
conv3 (Conv2D)                  (None,64)  27712       pool2[0][0]                      
__________________________________________________________________________________________________
bn3 (Batchnormalization)        (None,64)  256         conv3[0][0]                      
__________________________________________________________________________________________________
elu3 (ELU)                      (None,64)  0           bn3[0][0]                        
__________________________________________________________________________________________________
pool3 (MaxPooling2D)            (None,37,60,64)   0           elu3[0][0]                       
__________________________________________________________________________________________________
conv4 (Conv2D)                  (None,64)   36928       pool3[0][0]                      
__________________________________________________________________________________________________
bn4 (Batchnormalization)        (None,64)   256         conv4[0][0]                      
__________________________________________________________________________________________________
elu4 (ELU)                      (None,64)   0           bn4[0][0]                        
__________________________________________________________________________________________________
pool4 (MaxPooling2D)            (None,18,30,64)   0           elu4[0][0]                       
__________________________________________________________________________________________________
conv5 (Conv2D)                  (None,48)   27696       pool4[0][0]                      
__________________________________________________________________________________________________
bn5 (Batchnormalization)        (None,48)   192         conv5[0][0]                      
__________________________________________________________________________________________________
elu5 (ELU)                      (None,48)   0           bn5[0][0]                        
__________________________________________________________________________________________________
pool5 (MaxPooling2D)            (None,9,15,48)    0           elu5[0][0]                       
__________________________________________________________________________________________________
conv6 (Conv2D)                  (None,48)    20784       pool5[0][0]                      
__________________________________________________________________________________________________
bn6 (Batchnormalization)        (None,48)    192         conv6[0][0]                      
__________________________________________________________________________________________________
elu6 (ELU)                      (None,48)    0           bn6[0][0]                        
__________________________________________________________________________________________________
pool6 (MaxPooling2D)            (None,4,7,48)     0           elu6[0][0]                       
__________________________________________________________________________________________________
conv7 (Conv2D)                  (None,32)     13856       pool6[0][0]                      
__________________________________________________________________________________________________
bn7 (Batchnormalization)        (None,32)     128         conv7[0][0]                      
__________________________________________________________________________________________________
elu7 (ELU)                      (None,32)     0           bn7[0][0]                        
__________________________________________________________________________________________________
classes4 (Conv2D)               (None,24)   13848       elu4[0][0]                       
__________________________________________________________________________________________________
classes5 (Conv2D)               (None,24)   10392       elu5[0][0]                       
__________________________________________________________________________________________________
classes6 (Conv2D)               (None,24)    10392       elu6[0][0]                       
__________________________________________________________________________________________________
classes7 (Conv2D)               (None,24)     6936        elu7[0][0]                       
__________________________________________________________________________________________________
Boxes4 (Conv2D)                 (None,16)   9232        elu4[0][0]                       
__________________________________________________________________________________________________
Boxes5 (Conv2D)                 (None,16)   6928        elu5[0][0]                       
__________________________________________________________________________________________________
Boxes6 (Conv2D)                 (None,16)    6928        elu6[0][0]                       
__________________________________________________________________________________________________
Boxes7 (Conv2D)                 (None,16)     4624        elu7[0][0]                       
__________________________________________________________________________________________________
classes4_reshape (Reshape)      (None,None,6)      0           classes4[0][0]                   
__________________________________________________________________________________________________
classes5_reshape (Reshape)      (None,6)      0           classes5[0][0]                   
__________________________________________________________________________________________________
classes6_reshape (Reshape)      (None,6)      0           classes6[0][0]                   
__________________________________________________________________________________________________
classes7_reshape (Reshape)      (None,6)      0           classes7[0][0]                   
__________________________________________________________________________________________________
anchors4 (AnchorBoxes)          (None,8) 0           Boxes4[0][0]                     
__________________________________________________________________________________________________
anchors5 (AnchorBoxes)          (None,8) 0           Boxes5[0][0]                     
__________________________________________________________________________________________________
anchors6 (AnchorBoxes)          (None,8)  0           Boxes6[0][0]                     
__________________________________________________________________________________________________
anchors7 (AnchorBoxes)          (None,8)   0           Boxes7[0][0]                     
__________________________________________________________________________________________________
classes_concat (Concatenate)    (None,6)      0           classes4_reshape[0][0]           
                                                                 classes5_reshape[0][0]           
                                                                 classes6_reshape[0][0]           
                                                                 classes7_reshape[0][0]           
__________________________________________________________________________________________________
Boxes4_reshape (Reshape)        (None,4)      0           Boxes4[0][0]                     
__________________________________________________________________________________________________
Boxes5_reshape (Reshape)        (None,4)      0           Boxes5[0][0]                     
__________________________________________________________________________________________________
Boxes6_reshape (Reshape)        (None,4)      0           Boxes6[0][0]                     
__________________________________________________________________________________________________
Boxes7_reshape (Reshape)        (None,4)      0           Boxes7[0][0]                     
__________________________________________________________________________________________________
anchors4_reshape (Reshape)      (None,8)      0           anchors4[0][0]                   
__________________________________________________________________________________________________
anchors5_reshape (Reshape)      (None,8)      0           anchors5[0][0]                   
__________________________________________________________________________________________________
anchors6_reshape (Reshape)      (None,8)      0           anchors6[0][0]                   
__________________________________________________________________________________________________
anchors7_reshape (Reshape)      (None,8)      0           anchors7[0][0]                   
__________________________________________________________________________________________________
classes_softmax (Activation)    (None,6)      0           classes_concat[0][0]             
__________________________________________________________________________________________________
Boxes_concat (Concatenate)      (None,4)      0           Boxes4_reshape[0][0]             
                                                                 Boxes5_reshape[0][0]             
                                                                 Boxes6_reshape[0][0]             
                                                                 Boxes7_reshape[0][0]             
__________________________________________________________________________________________________
anchors_concat (Concatenate)    (None,8)      0           anchors4_reshape[0][0]           
                                                                 anchors5_reshape[0][0]           
                                                                 anchors6_reshape[0][0]           
                                                                 anchors7_reshape[0][0]           
__________________________________________________________________________________________________
predictions (Concatenate)       (None,18)     0           classes_softmax[0][0]            
                                                                 Boxes_concat[0][0]               
                                                                 anchors_concat[0][0]             
==================================================================================================
Total params: 213,904
Trainable params: 213,232
Non-trainable params: 672
  1. 使用 model.load() 加载相同的模型并在模型的卷积层上应用量化。现在量化的 model.summary() 如下所示
Model: "model"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_1 (InputLayer)            [(None,3)  0           identity_layer[1][0]             
__________________________________________________________________________________________________
input_stddev_normalization (Lam (None,3)  0           input_mean_normalization[1][0]   
__________________________________________________________________________________________________
quant_conv1 (QuantizeWrapper)   (None,32) 2499        input_stddev_normalization[1][0] 
__________________________________________________________________________________________________
bn1 (Batchnormalization)        (None,32) 128         quant_conv1[0][0]                
__________________________________________________________________________________________________
elu1 (ELU)                      (None,32) 0           bn1[1][0]                        
__________________________________________________________________________________________________
pool1 (MaxPooling2D)            (None,32) 0           elu1[1][0]                       
__________________________________________________________________________________________________
quant_conv2 (QuantizeWrapper)   (None,48) 13971       pool1[1][0]                      
__________________________________________________________________________________________________
bn2 (Batchnormalization)        (None,48) 192         quant_conv2[0][0]                
__________________________________________________________________________________________________
elu2 (ELU)                      (None,48) 0           bn2[1][0]                        
__________________________________________________________________________________________________
pool2 (MaxPooling2D)            (None,48)  0           elu2[1][0]                       
__________________________________________________________________________________________________
quant_conv3 (QuantizeWrapper)   (None,64)  27843       pool2[1][0]                      
__________________________________________________________________________________________________
bn3 (Batchnormalization)        (None,64)  256         quant_conv3[0][0]                
__________________________________________________________________________________________________
elu3 (ELU)                      (None,64)  0           bn3[1][0]                        
__________________________________________________________________________________________________
pool3 (MaxPooling2D)            (None,64)   0           elu3[1][0]                       
__________________________________________________________________________________________________
quant_conv4 (QuantizeWrapper)   (None,64)   37059       pool3[1][0]                      
__________________________________________________________________________________________________
bn4 (Batchnormalization)        (None,64)   256         quant_conv4[0][0]                
__________________________________________________________________________________________________
elu4 (ELU)                      (None,64)   0           bn4[1][0]                        
__________________________________________________________________________________________________
pool4 (MaxPooling2D)            (None,64)   0           elu4[1][0]                       
__________________________________________________________________________________________________
quant_conv5 (QuantizeWrapper)   (None,48)   27795       pool4[1][0]                      
__________________________________________________________________________________________________
bn5 (Batchnormalization)        (None,48)   192         quant_conv5[0][0]                
__________________________________________________________________________________________________
elu5 (ELU)                      (None,48)   0           bn5[1][0]                        
__________________________________________________________________________________________________
pool5 (MaxPooling2D)            (None,48)    0           elu5[1][0]                       
__________________________________________________________________________________________________
quant_conv6 (QuantizeWrapper)   (None,48)    20883       pool5[1][0]                      
__________________________________________________________________________________________________
bn6 (Batchnormalization)        (None,48)    192         quant_conv6[0][0]                
__________________________________________________________________________________________________
elu6 (ELU)                      (None,48)    0           bn6[1][0]                        
__________________________________________________________________________________________________
pool6 (MaxPooling2D)            (None,48)     0           elu6[1][0]                       
__________________________________________________________________________________________________
quant_conv7 (QuantizeWrapper)   (None,32)     13923       pool6[1][0]                      
__________________________________________________________________________________________________
bn7 (Batchnormalization)        (None,32)     128         quant_conv7[0][0]                
__________________________________________________________________________________________________
elu7 (ELU)                      (None,32)     0           bn7[1][0]                        
__________________________________________________________________________________________________
quant_classes4 (QuantizeWrapper (None,24)   13899       elu4[1][0]                       
__________________________________________________________________________________________________
quant_classes5 (QuantizeWrapper (None,24)   10443       elu5[1][0]                       
__________________________________________________________________________________________________
quant_classes6 (QuantizeWrapper (None,24)    10443       elu6[1][0]                       
__________________________________________________________________________________________________
quant_classes7 (QuantizeWrapper (None,24)     6987        elu7[1][0]                       
__________________________________________________________________________________________________
quant_Boxes4 (QuantizeWrapper)  (None,16)   9267        elu4[1][0]                       
__________________________________________________________________________________________________
quant_Boxes5 (QuantizeWrapper)  (None,16)   6963        elu5[1][0]                       
__________________________________________________________________________________________________
quant_Boxes6 (QuantizeWrapper)  (None,16)    6963        elu6[1][0]                       
__________________________________________________________________________________________________
quant_Boxes7 (QuantizeWrapper)  (None,16)     4659        elu7[1][0]                       
__________________________________________________________________________________________________
classes4_reshape (Reshape)      (None,6)      0           quant_classes4[0][0]             
__________________________________________________________________________________________________
classes5_reshape (Reshape)      (None,6)      0           quant_classes5[0][0]             
__________________________________________________________________________________________________
classes6_reshape (Reshape)      (None,6)      0           quant_classes6[0][0]             
__________________________________________________________________________________________________
classes7_reshape (Reshape)      (None,6)      0           quant_classes7[0][0]             
__________________________________________________________________________________________________
anchors4 (AnchorBoxes)          (None,8) 0           quant_Boxes4[0][0]               
__________________________________________________________________________________________________
anchors5 (AnchorBoxes)          (None,8) 0           quant_Boxes5[0][0]               
__________________________________________________________________________________________________
anchors6 (AnchorBoxes)          (None,8)  0           quant_Boxes6[0][0]               
__________________________________________________________________________________________________
anchors7 (AnchorBoxes)          (None,8)   0           quant_Boxes7[0][0]               
__________________________________________________________________________________________________
classes_concat (Concatenate)    (None,6)      0           classes4_reshape[1][0]           
                                                                 classes5_reshape[1][0]           
                                                                 classes6_reshape[1][0]           
                                                                 classes7_reshape[1][0]           
__________________________________________________________________________________________________
Boxes4_reshape (Reshape)        (None,4)      0           quant_Boxes4[0][0]               
__________________________________________________________________________________________________
Boxes5_reshape (Reshape)        (None,4)      0           quant_Boxes5[0][0]               
__________________________________________________________________________________________________
Boxes6_reshape (Reshape)        (None,4)      0           quant_Boxes6[0][0]               
__________________________________________________________________________________________________
Boxes7_reshape (Reshape)        (None,4)      0           quant_Boxes7[0][0]               
__________________________________________________________________________________________________
anchors4_reshape (Reshape)      (None,8)      0           anchors4[1][0]                   
__________________________________________________________________________________________________
anchors5_reshape (Reshape)      (None,8)      0           anchors5[1][0]                   
__________________________________________________________________________________________________
anchors6_reshape (Reshape)      (None,8)      0           anchors6[1][0]                   
__________________________________________________________________________________________________
anchors7_reshape (Reshape)      (None,8)      0           anchors7[1][0]                   
__________________________________________________________________________________________________
classes_softmax (Activation)    (None,6)      0           classes_concat[1][0]             
__________________________________________________________________________________________________
Boxes_concat (Concatenate)      (None,4)      0           Boxes4_reshape[1][0]             
                                                                 Boxes5_reshape[1][0]             
                                                                 Boxes6_reshape[1][0]             
                                                                 Boxes7_reshape[1][0]             
__________________________________________________________________________________________________
anchors_concat (Concatenate)    (None,8)      0           anchors4_reshape[1][0]           
                                                                 anchors5_reshape[1][0]           
                                                                 anchors6_reshape[1][0]           
                                                                 anchors7_reshape[1][0]           
__________________________________________________________________________________________________
predictions (Concatenate)       (None,18)     0           classes_softmax[1][0]            
                                                                 Boxes_concat[1][0]               
                                                                 anchors_concat[1][0]             
==================================================================================================
Total params: 214,941
Trainable params: 213,232
Non-trainable params: 1,709

  1. 现在我必须将这个 quantized_model.h5 文件转换为应用程序的 quantized_model.pb 文件
  2. 我已成功转换为 quantized_model.pb 文件,但现在当我尝试加载 quantized_model.pb 文件时,出现以下错误
Error creating graph: Invalid argument: Input 0 of node quant_conv1/cond/LastValueQuant/AssignMinLast was passed float from quant_conv1/cond/LastValueQuant/AssignMinLast/Switch:1 incompatible with expected resource

有人可以帮助我吗。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...