Open M-Tonin opened 4 years ago
The error was made by :
k_model_onnx = onnx_to_keras(onnx_model, 'lstm_input', name_policy="short")
I forget to put "[lstm_input]"
The real error is:
AttributeError Traceback (most recent call last)
Getting the same error. Were you able to solve it?
Not yet, I used onnxruntime to this model
Hello @M-Tonin @vipulbjj .
Unfortunately, recurrent layers are not supported now. ONNX produces a bunch of low-level operations, and something doesn't match somewhere in the middle. I don't want to write ad-hoc for LSTM / GRU / etc, because in the end it will not work optimal using TF / Keras anyway (TF/Keras have high-level layers for RNNs).
I know it's necessary features, but it can't be solved without new ONNX / any-other-good-way-to-export-graph (if you use PyTorch, for example).
Hi @nerox8664 is there some way we can use an older version of Keras/Onnx so that this will work? If not do you know how we can resolve this? It's still an important issue that needs to be resolved, especially for users that need to convert a MATLAB model into Python TensorFlow/Keras. Also, in your last sentence you mention that: "it can't be solved without new ONNX / any-other-good-way-to-export-graph (if you use PyTorch, for example". Does this mean that if I used pytorch2keras or some kind of PyTorch function then it would still work? Thank you!
Hey, doing the basic step, to LSTM model. ``
Returns a compiled model identical to the previous one
onnx_model = onnx.load("stock_price.onnx") k_model_onnx = onnx_to_keras(onnx_model, 'lstm_input', name_policy="short") k_model_onnx.graph = tf.compat.v1.get_default_graph() weights_onnx = k_model_onnx.get_weights()
``
`` INFO:onnx2keras:Converter is called. DEBUG:onnx2keras:List input shapes: DEBUG:onnx2keras:None DEBUG:onnx2keras:List inputs: DEBUG:onnx2keras:Input 0 -> lstm_input. DEBUG:onnx2keras:List outputs: DEBUG:onnx2keras:Output 0 -> dense. DEBUG:onnx2keras:Gathering weights to dictionary. DEBUG:onnx2keras:Found weight dense/kernel:0 with shape (256, 1). DEBUG:onnx2keras:Found weight dense/bias:0 with shape (1,). DEBUG:onnx2keras:Found weight W with shape (1, 1024, 256). DEBUG:onnx2keras:Found weight R with shape (1, 1024, 256). DEBUG:onnx2keras:Found weight B with shape (1, 2048). DEBUG:onnx2keras:Found weight shape_tensor with shape (2,). DEBUG:onnx2keras:Found weight W1 with shape (1, 1024, 256). DEBUG:onnx2keras:Found weight R1 with shape (1, 1024, 256). DEBUG:onnx2keras:Found weight B1 with shape (1, 2048). DEBUG:onnx2keras:Found weight dropout/Identity:0_seq_len_tensor_start with shape (1,). DEBUG:onnx2keras:Found weight dropout/Identity:0_seq_len_tensor_end with shape (1,). DEBUG:onnx2keras:Found weight dropout/Identity:0_seq_len_tensor_axes with shape (1,). DEBUG:onnx2keras:Found weight dropout/Identity:0_output_seq_shape_a with shape (1,). DEBUG:onnx2keras:Found weight dropout/Identity:0_output_seq_shape_b with shape (1,). DEBUG:onnx2keras:Found weight W2 with shape (1, 1024, 70). DEBUG:onnx2keras:Found weight R2 with shape (1, 1024, 256). DEBUG:onnx2keras:Found weight B2 with shape (1, 2048). DEBUG:onnx2keras:Found weight lstm_input:01_seq_len_tensor_start with shape (1,). DEBUG:onnx2keras:Found weight lstm_input:01_seq_len_tensor_end with shape (1,). DEBUG:onnx2keras:Found weight lstm_input:01_seq_len_tensor_axes with shape (1,). DEBUG:onnx2keras:Found weight lstm_input:01_output_seq_shape_a with shape (1,). DEBUG:onnx2keras:Found weight lstm_input:01_output_seq_shape_b with shape (1,). DEBUG:onnx2keras:###### DEBUG:onnx2keras:... DEBUG:onnx2keras:Converting ONNX operation DEBUG:onnx2keras:type: Identity DEBUG:onnx2keras:node_name: lstm_input:01 DEBUG:onnx2keras:node_params: {'change_ordering': False, 'name_policy': 'short'} DEBUG:onnx2keras:... DEBUG:onnx2keras:Check if all inputs are available: DEBUG:onnx2keras:Check input 0 (name lstm_input). DEBUG:onnx2keras:The input not found in layers / model inputs.
AttributeError Traceback (most recent call last)