Open luan1412167 opened 4 years ago
@luan1412167 May you please clarify when you get this error
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 25600 and 512 for 'MatMul_149' (op: 'MatMul') with input shapes: [1,25600], [512,128]
Is it when you run prepare or tf_rep.run or when you run it in tflite? I can run prepare successfully, but I don't know what is the input data to run your model, may you provide us a sample input data please?
Describe the bug hi there, I'm converting pytorch (1) --> ONNX (2) --> pb (3) --> tf-lite (4). which
WARNING:tensorflow:From /home/dmp/Downloads/onnx-tensorflow/onnx_tf/handlers/backend/reshape.py:31: sparse_to_dense (from tensorflow.python.ops.sparse_ops) is deprecated and will be removed in a future version. Instructions for updating:
Create a
tf.sparse.SparseTensorand use
tf.sparse.to_denseinstead.
Traceback (most recent call last):
File "/home/dmp/Silent-Face-Anti-Spoofing/luandd/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 1607, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 25600 and 512 for 'MatMul_149' (op: 'MatMul') with input shapes: [1,25600], [512,128]
Anyone help me clarify what happen with MatMul function? Thanks for supporting and highly appreciated
A clear and concise description of what the bug is. Bug is at MatMul function:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 25600 and 512 for 'MatMul_149' (op: 'MatMul') with input shapes: [1,25600], [512,128]
To Reproduce This is pytorch2onnx code:torch.onnx.export(anti_model.model, dummy_input, converted_model + "/model_new.onnx", input_names=['test_input'], output_names=['test_output'])
This is onnx2pb code:model_onnx = onnx.load('./resources/converted_models/model_new.onnx')
dummy_img = cv2.imread("./datasets/RGB_Images/1.2_112x112/test_caffee_model/1/1599816472827_3.png")
tf_rep = prepare(model_onnx, strict=True)
dummy_input = transform_input(dummy_img)
# Export model as .pb file
tf_rep.export_graph('./resources/converted_models/tfmodel.pb')
print(pb_path)
This is pb2tflite command:
toco --graph_def_file resources/converted_models/tfmodel.pb \ --output_file resources/converted_models/tfmodel.tflite \ --output_format TFLITE \ --inference_type FLOAT \ --inference_input_type FLOAT \ --input_arrays test_input \ --output_arrays test_output
This is the onnx model
Please give us instructions to reproduce your problem.
A self-contained piece of code that can demonstrate the problem is required.
Please do not expect us to have PyTorch, Caffe2 installed.
If a model exported from PyTorch and Caffe2 is having trouble in ONNX-TF, use the next section to attach the model.
ONNX model file
If applicable, attach the onnx model file in question using Gist, DropBox or Google Drive.
Python, ONNX, ONNX-TF, Tensorflow version
This section can be obtained by running
get_version.py
from util folder.Additional context
Add any other context about the problem here.