onnx2pytorch
onnx2pytorch copied to clipboard
UserWarning: NumPy array is not writeable
When converting an onnx model to pytorch I'm getting this warning:
UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor
It's caused by a method load_params() in onnx2pytorch\convert\layer.py and line 138 in onnx2pytorch\convert\model.py.
For example when this torch.from_numpy(numpy_helper.to_array(tensor)) is modified to use the numpy copy torch.from_numpy(np.copy(numpy_helper.to_array(tensor))) then all the warnings are gone.
Please, can you comment on this?
I'm getting this as well. I'm only loading these so that I can modify the weights before exporting them as an onnx model again. Should I be concerned about this?
Probably not
This was fixed in v0.5.2