简体   繁体   English

Python Numpy einsum klij->kijl 和 kijl->klij 它们是什么意思?

[英]Python Numpy einsum klij->kijl and kijl->klij what do they mean?

I am trying to understand the following code from https://github.com/rezazad68/BCDU-Net/blob/master/Retina%20Blood%20Vessel%20Segmentation/evaluate.py :我试图从https://github.com/rezazad68/BCDU-Net/blob/master/Retina%20Blood%20Vessel%20Segmentation/evaluate.py理解以下代码:

patches_imgs_test = np.einsum('klij->kijl', patches_imgs_test)

and also the following:以及以下内容:

predictions = np.einsum('kijl->klij', predictions)

I tried looking up the einsum operands klij->kijl and kijl->klij but lady luck has yet to be on my side.我尝试查找einsum操作数klij->kijlkijl->klij但幸运kijl->klij尚未站在我这边。 The closest I got (probably) are the following which do not explain cases with '4 charcters':我得到的最接近的(可能)是以下没有解释“4个字符”的情况:

https://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html Understanding NumPy's einsum https://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html 了解 NumPy 的 einsum

My intuition is that its just rotations of the images based on how the characters are shifting.我的直觉是,它只是根据角色的移动方式来旋转图像。 Am I right or close on this?我是对的还是接近这一点? Some insights will be appreciated!一些见解将不胜感激!

PS The numpy einsum documentation is killing me.. PS numpy einsum文档正在杀死我..

The provided einsum statement is equivalent to (using np.moveaxis ):提供的einsum语句等效于(使用np.moveaxis ):

 patches_imgs_test  = np.moveaxis(patches_imgs_test, 1, -1)

followed by:其次是:

predictions = np.moveaxis(predictions, -1, 1)

Basically, moving the second axis to the end, and then putting it back in the results.基本上,将第二个轴移动到最后,然后将其放回结果中。

In this case, it's patches of pictures being dumped into a neural network.在这种情况下,它是将图片块转储到神经网络中。 The second and fourth axes are the actual patches, so the code puts them at the end before passing to the NN, while the first and third axes are location data.第二个和第四个轴是实际的补丁,因此代码在传递到 NN 之前将它们放在最后,而第一和第三个轴是位置数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM