convert_from_tensorflow.py: add support when kernel size is 1*1 with one input/output...
authorGuo, Yejun <yejun.guo@intel.com>
Fri, 22 Nov 2019 07:50:04 +0000 (15:50 +0800)
committerPedro Arthur <bygrandao@gmail.com>
Fri, 13 Dec 2019 14:41:10 +0000 (11:41 -0300)
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
tools/python/convert_from_tensorflow.py

index 605158a..5e87e22 100644 (file)
@@ -193,7 +193,10 @@ class TFConverter:
         filter_width = ktensor.tensor_shape.dim[1].size
         in_channels = ktensor.tensor_shape.dim[2].size
         out_channels = ktensor.tensor_shape.dim[3].size
-        kernel = np.frombuffer(ktensor.tensor_content, dtype=np.float32)
+        if filter_height * filter_width * in_channels * out_channels == 1:
+            kernel = np.float32(ktensor.float_val[0])
+        else:
+            kernel = np.frombuffer(ktensor.tensor_content, dtype=np.float32)
         kernel = kernel.reshape(filter_height, filter_width, in_channels, out_channels)
         kernel = np.transpose(kernel, [3, 0, 1, 2])