Encountered this error when writing code in python:
File "/home/dwt/MyCode/pycharm_projects/YOLOX/yolox/models/darknet_search.py", line 196, in <listcomp>
self.dark3 = nn.Sequential(*[PRIMITIVES[block_names[i]](*input_parameter(i))
│ │ │ │ │ └ 4
│ │ │ │ └ 4
│ │ │ └ [['ir_k3_e3'], ['ir_k3_e6'], ['ir_k3_e6'], ['ir_k3_e6'], ['ir_k3_e6'], ['ir_k5_e1'], ['ir_k3_e6'], ['skip'], ['ir_k5_s2'], ['...
│ │ └ {'skip': <function <lambda> at 0x7f9069d7a9d0>, 'ir_k3': <function <lambda> at 0x7f9069d7aa60>, 'ir_k5': <function <lambda> a...
│ └ <class 'torch.nn.modules.container.Sequential'>
└ <module 'torch.nn' from '/home/dwt/anaconda3/envs/fbnet_yolox/lib/python3.8/site-packages/torch/nn/__init__.py'>
TypeError: unhashable type: 'list'
Reason for error: because the input_parameter in the code is a list storing several tuples, the content is as follows:
input_parameter = [
(32, 64, -999, 2), (64, 64, -999, 1), (64, 64, -999, 1), (64, 64, -999, 1),
(64, 128, -999, 2), (128, 128, -999, 1), (128, 128, -999, 1), (128, 128, -999, 1),
(128, 256, -999, 2), (256, 256, -999, 1), (256, 256, -999, 1), (256, 256, -999, 1),
(256, 512, -999, 2), (256, 512, -999, 1), (256, 512, -999, 1), (256, 512, -999, 1),
]
The error is "input_parameter(i)" . When indexing the elements in the list, the index value should be marked with square brackets instead of parentheses. Just change " input_parameter(i)" to "input_parameter[i]" .