在numpy数组上进行flip操作之后,遇到如下问题:
ValueError: some of the strides of a given numpy array are negative. This is currently not supported, but will be added in future releases.
原因是进行flip之后,numpy数组的内存不连续,而Dataloader要求tensor对应的numpy是连续的。
解决方法:使用copy()进行拷贝,拷贝之后的内存是连续的。
array = array[:, :, ::-1].copy()
网友评论