It looks like there might be an issue with the data type being passed to the float() function. Here are a few suggestions to help address this:
Check the Data Type: Let’s first verify the type of data being passed to float(). You can insert a print statement just before the line that triggers the error:
print(type(next(iter(var_initializers.values()))))
print(next(iter(var_initializers.values())))
power = float(next(iter(var_initializers.values())).tolist())
This will help us identify the data type.
Handle List Input: If the value is a list (as the error message suggests), you might need to extract the first element before converting it to a float:
value = next(iter(var_initializers.values())).tolist()
if isinstance(value, list):
power = float(value[0]) # Use the first element if it's a list
else:
power = float(value)
Check for Nested Structures: If the data structure is more complex, you might need to navigate through nested lists or arrays:
value = next(iter(var_initializers.values())).tolist()
while isinstance(value, list) and len(value) > 0:
value = value[0]
power = float(value)
Ensure Consistent Data Types: Verify that all values in var_initializers have the same type and structure to avoid unexpected behavior.
Debug var_initializers: Print out the contents of var_initializers to understand its structure:
print(var_initializers)
This can provide insight into the type and structure of the data you’re handling.
6. Check the ONNX Model: If this error is occurring during the parsing of an ONNX model, there might be an issue with the model export or the specific operator being processed. Verify that the ONNX model is valid and that all operators are supported by the Hailo Dataflow Compiler.
If none of these solutions work, please provide more context about where this code is in your project and what operation you’re trying to perform. This will help in offering a more targeted solution.