How to export CV Mat to 4D-npy/npz, hdf5 or zarr?

if you are talking about python, net.forward() will result in a numpy array, you can simply use numpy.save()to serialize it
if it’s really c++, take a look at the tests, there’s npy code .
you could also use cv::FileStorage

tell us, what your network does. does it use some “known” architecture ?