Open HarHarLinks opened 2 years ago
I was able to overcome this by this method: https://stackoverflow.com/questions/47895494/how-to-convert-all-layers-of-a-pretrained-keras-model-to-a-different-dtype-from
i.e. since my model uses only float64, I changed converter.py of onnx2keras thusly:
@@ -3,6 +3,7 @@
"""
from tensorflow import keras
+from tensorflow.keras import backend as K
import logging
import inspect
import collections
@@ -48,6 +49,8 @@
:param change_ordering: change ordering to HWC (experimental)
:return: Keras model
"""
+ K.set_floatx('float64')
+
# Use channels first format by default.
keras_fmt = keras.backend.image_data_format()
keras.backend.set_image_data_format('channels_first')
However I'm posting this here merely as a hardcoded workaround, so this still should be addressed properly by someone who actually understands how the converter works.
I don't know whether this issue is actually with this project (the "pytorch2onnx" part) or rather onnx2keras. Please move it if applicable.
Describe the bug I'm trying to convert a model that uses double (float64) datatype throughout, it looks like this, created with
torch.jit.script
.Expected behavior double -> double
Script