TypeError: 'Lambda' object does not support item assignment
See original GitHub issueHi, I tried to load a simple two layered ONNX model exported with pytorch:
k_model = onnx2keras.onnx_to_keras("simple_cnn.txt", ["input.1"])
but, i got the following output and error:
2021-04-19 17:53:04.793268: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/user/torch/install/lib::/usr/local/cuda:/usr/local/cuda-10.0/lib64
2021-04-19 17:53:04.793300: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
INFO:onnx2keras:Converter is called.
DEBUG:onnx2keras:List input shapes:
DEBUG:onnx2keras:None
DEBUG:onnx2keras:List inputs:
DEBUG:onnx2keras:Input 0 -> input.1.
DEBUG:onnx2keras:List outputs:
DEBUG:onnx2keras:Output 0 -> 9.
DEBUG:onnx2keras:Gathering weights to dictionary.
DEBUG:onnx2keras:Found weight conv.weight with shape (8, 5, 3).
DEBUG:onnx2keras:Found weight conv.bias with shape (8,).
DEBUG:onnx2keras:Found weight fc.weight with shape (2, 80).
DEBUG:onnx2keras:Found weight fc.bias with shape (2,).
DEBUG:onnx2keras:Found input input.1 with shape [5, 10]
DEBUG:onnx2keras:######
DEBUG:onnx2keras:...
DEBUG:onnx2keras:Converting ONNX operation
DEBUG:onnx2keras:type: Conv
DEBUG:onnx2keras:node_name: 5
DEBUG:onnx2keras:node_params: {'dilations': [1], 'group': 1, 'kernel_shape': [3], 'pads': [1, 1], 'strides': [1], 'change_ordering': False, 'name_policy': None}
DEBUG:onnx2keras:...
DEBUG:onnx2keras:Check if all inputs are available:
DEBUG:onnx2keras:Check input 0 (name input.1).
DEBUG:onnx2keras:Check input 1 (name conv.weight).
DEBUG:onnx2keras:The input not found in layers / model inputs.
DEBUG:onnx2keras:Found in weights, add as a numpy constant.
DEBUG:onnx2keras:Check input 2 (name conv.bias).
DEBUG:onnx2keras:The input not found in layers / model inputs.
DEBUG:onnx2keras:Found in weights, add as a numpy constant.
DEBUG:onnx2keras:... found all, continue
DEBUG:onnx2keras:conv:Conv with bias
3 5 8 True
Traceback (most recent call last):
File "onnx_2_keras.py", line 19, in <module>
k_model = onnx2keras.onnx_to_keras(onnx_model, input_all)
File "/home/user/.local/lib/python3.6/site-packages/onnx2keras/converter.py", line 181, in onnx_to_keras
keras_names
File "/home/user/.local/lib/python3.6/site-packages/onnx2keras/convolution_layers.py", line 197, in convert_conv
lambda_layer[keras_name] = target_layer
TypeError: 'Lambda' object does not support item assignment
I have tensorflow 2.4.1, keras 2.4.3 and no CUDA.
Edit: The problem occurs because of the use of Conv1D
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Lambda error "TypeError: 'str' object does not support item ...
Based on the posted form of the event , you should use ast , not json import ast item = ast.literal_eval(event['body']).
Read more >TypeError: 'type' object does not support item assignment
The Python "TypeError: 'type' object does not support item assignment" occurs when we assign a data type to a variable and use square...
Read more >'str' Object Does Not Support Item Assignment - Python Pool
When you alter characters using the assignment operator, you will receive TypeError:'str' Object Does Not Support Item Assignment.
Read more >'str' object does not support item assignment Traceback - Higgs
Lambda error "TypeError: 'str' object does not support item assignment Traceback". Detection score: 1. Current body; Last body; Edit summary.
Read more >Python 'str' object does not support item assignment solution
Let's start by taking a look at our error: Typeerror: 'str' object does not support item assignment. This error message tells us that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@londumas , actually it replaces Conv1d in PyTorch by Lambda layer with fixed weights in Keras, so it has no prams. But the result is still the same. If their results are different, you can replace the code from line 179 in the file onnx2keras/convolution_layers.py with the following code: `
1D conv
`
At line 197 on file onnx2keras/convolution_layers.py, you change
lambda_layer[keras_name] = target_layertolambda_func[keras_name] = target_layer.