Когда я запускаю файл tflite, он просто показывает «aborted (core dumped)» - PullRequest
0 голосов
/ 23 сентября 2019

Когда я использую tf версии 1.13.1 для преобразования pb в tflite, он показывает dim not matched ошибку, но когда я использую 1.14 для преобразования, он успешно сохраняет tfliteфайл.Но когда я использую тестовый код в документе, он просто показывает core dumped .

Вот вывод:

, преобразованный с 1.13.1

 ture_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA  
2019-09-23 14:33:07.069746: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3696000000 Hz  
2019-09-23 14:33:07.072588: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x564ecd24a790 executing computations on platform Host. Devices:  
2019-09-23 14:33:07.072658: I tensorflow/compiler/xla/service/service.cc:158]   StreamExecutor device (0): <undefined>, <undefined>  
Ignore 'tcmalloc: large alloc' warnings.  
Traceback (most recent call last):  
  File "pb-to-tflite.py", line 9, in <module>  
    tflite_model = converter.convert()  
  File "/home/dm/anaconda3/envs/s-t3/lib/python3.6/site- 
 packages/tensorflow/lite/python/lite.py", line 455, in convert  
    **converter_kwargs)  
  File "/home/dm/anaconda3/envs/s-t3/lib/python3.6/site- 
 packages/tensorflow/lite/python/convert.py", line 442, in toco_convert_impl  
    input_data.SerializeToString())  
  File "/home/dm/anaconda3/envs/s-t3/lib/python3.6/site-packages/tensorflow/lite/python/convert.py", line 205, in toco_convert_protos  
    "TOCO failed. See console for info.\n%s\n%s\n" % (stdout, stderr))
tensorflow.lite.python.convert.ConverterError: TOCO failed. See console for info.  
2019-09-23 14:33:21.269591: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before Removing unused ops: 529 operators, 854 arrays (0 quantized)  
2019-09-23 14:33:21.275653: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] After Removing unused ops pass 1: 527 operators, 849 arrays (0 quantized)  
2019-09-23 14:33:21.283483: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 527 operators, 849 arrays (0 quantized)  
2019-09-23 14:33:21.330461: F tensorflow/lite/toco/graph_transformations/propagate_fixed_sizes.cc:117] Check failed: dim_x == dim_y (512 vs. 10)Dimensions must match  
Aborted (core dumped) 

конвертируется в 1,14

2019-09-23 14:38:45.285133: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:716] Optimization results for grappler item: graph_to_optimize  
2019-09-23 14:38:45.285519: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718]   constant folding: Graph size after: 440 nodes (-112), 631 edges (-112), time = 213.324ms.  
2019-09-23 14:38:45.285580: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718]   constant folding: Graph size after: 440 nodes (0), 631 edges (0), time = 54.184ms.  

, и когда я использую приведенный ниже код для проверки


import tensorflow as tf
import numpy as np

# Load TFLite model and allocate tensors.
interpreter = tf.lite.Interpreter(model_path="converted_model.tflite")
interpreter.allocate_tensors()

# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
print(input_details)
print(output_details)
# Test model on random input data.
input_shape = input_details[0]['shape']
input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)
print(input_data.shape)
interpreter.set_tensor(input_details[0]['index'], input_data)

interpreter.invoke()
# The function `get_tensor()` returns a copy of the tensor data.
# Use `tensor()` in order to get a pointer to the tensor.
output_data = interpreter.get_tensor(output_details[0]['index'])
print(output_data)

, он просто показывает

 [{'name': 'input', 'index': 95, 'shape': array([  1, 257, 400,   1], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0)}]  
[{'name': 'lambda_1/l2_normalize', 'index': 96, 'shape': array([  1, 512], dtype=int32), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0)}]  
(1, 257, 400, 1)  
Aborted (core dumped)  

, и я могу использоватьnetron, чтобы открыть сгенерированный файл tflite структура сети, которую он показывает

кто-нибудь может мне помочь?

...