首先,Keras 格式是(samples, height, width, channels).
您需要做的就是一个moved = numpy.moveaxis(data, -1,1)
如果幸运的是您使用的是非默认 config "channels_first",那么该配置与 PyTorch 的相同,即(samples, channels, height, width).
当转换为火炬时: data = torch.from_numpy(moved)
| 归档时间: |
|
| 查看次数: |
1587 次 |
| 最近记录: |