• <tfoot id='eY5ta'></tfoot>

      <small id='eY5ta'></small><noframes id='eY5ta'>

      <i id='eY5ta'><tr id='eY5ta'><dt id='eY5ta'><q id='eY5ta'><span id='eY5ta'><b id='eY5ta'><form id='eY5ta'><ins id='eY5ta'></ins><ul id='eY5ta'></ul><sub id='eY5ta'></sub></form><legend id='eY5ta'></legend><bdo id='eY5ta'><pre id='eY5ta'><center id='eY5ta'></center></pre></bdo></b><th id='eY5ta'></th></span></q></dt></tr></i><div id='eY5ta'><tfoot id='eY5ta'></tfoot><dl id='eY5ta'><fieldset id='eY5ta'></fieldset></dl></div>
        <legend id='eY5ta'><style id='eY5ta'><dir id='eY5ta'><q id='eY5ta'></q></dir></style></legend>

        • <bdo id='eY5ta'></bdo><ul id='eY5ta'></ul>
      1. 朱莉娅的numpy.einsum?(2)

        时间:2023-10-19
            <bdo id='6f0yK'></bdo><ul id='6f0yK'></ul>

            <small id='6f0yK'></small><noframes id='6f0yK'>

                  <i id='6f0yK'><tr id='6f0yK'><dt id='6f0yK'><q id='6f0yK'><span id='6f0yK'><b id='6f0yK'><form id='6f0yK'><ins id='6f0yK'></ins><ul id='6f0yK'></ul><sub id='6f0yK'></sub></form><legend id='6f0yK'></legend><bdo id='6f0yK'><pre id='6f0yK'><center id='6f0yK'></center></pre></bdo></b><th id='6f0yK'></th></span></q></dt></tr></i><div id='6f0yK'><tfoot id='6f0yK'></tfoot><dl id='6f0yK'><fieldset id='6f0yK'></fieldset></dl></div>
                    <tbody id='6f0yK'></tbody>
                • <tfoot id='6f0yK'></tfoot>
                  <legend id='6f0yK'><style id='6f0yK'><dir id='6f0yK'><q id='6f0yK'></q></dir></style></legend>
                  本文介绍了朱莉娅的numpy.einsum?(2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  来自这个问题,我想知道是否有可能更广义的einsum.让我们假设,我有问题

                  Coming from this question, I wonder if a more generalized einsum was possible. Let us assume, I had the problem

                  using PyCall
                  @pyimport numpy as np
                  
                  a = rand(10,10,10)
                  b = rand(10,10)
                  c = rand(10,10,10)
                  
                  Q = np.einsum("imk,ml,lkj->ij", a,b,c)
                  

                  或者类似的东西,我如何在不循环求和的情况下解决这个问题?

                  Or something similar, how were I to solve this problem without looping through the sums?

                  致以最诚挚的问候

                  推荐答案

                  编辑/更新: 现在这是一个注册包,所以你可以 Pkg.add("Einsum"),您应该一切顺利(请参阅下面的示例以开始使用).

                  Edit/Update: This is now a registered package, so you can Pkg.add("Einsum") and you should be good to go (see the example below to get started).

                  原答案:我刚刚创建了一些非常初步的代码来执行此操作.它完全符合马特 B. 在他的评论中描述的内容.希望对你有帮助,如果有问题请告诉我.

                  Original Answer: I just created some very preliminary code to do this. It follows exactly what Matt B. described in his comment. Hope it helps, let me know if there are problems with it.

                  https://github.com/ahwillia/Einsum.jl

                  这就是你将如何实现你的例子:

                  This is how you would implement your example:

                  using Einsum
                  
                  a = rand(10,10,10)
                  b = rand(10,10)
                  c = rand(10,10,10)
                  Q = zeros(10,10)
                  
                  @einsum Q[i,j] = a[i,m,k]*b[m,l]*c[l,k,j]
                  

                  在底层,宏构建了以下一系列嵌套 for 循环,并在编译前将它们插入到您的代码中.(注意这不是插入的确切代码,它还会检查以确保输入的尺寸一致,使用 macroexpand 查看完整代码):

                  Under the hood the macro builds the following series of nested for loops and inserts them into your code before compile time. (Note this is not the exact code inserted, it also checks to make sure the dimensions of the inputs agree, using macroexpand to see the full code):

                  for j = 1:size(Q,2)
                      for i = 1:size(Q,1)
                          s = 0
                          for l = 1:size(b,2)
                              for k = 1:size(a,3)
                                  for m = 1:size(a,2)
                                      s += a[i,m,k] * b[m,l] * c[l,k,j]
                                  end
                              end
                          end
                          Q[i,j] = s
                      end
                  end
                  

                  这篇关于朱莉娅的numpy.einsum?(2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:当 Jupyter 单元包含函数、循环或其他块时,是否可以跨单元拆分它? 下一篇:埃拉托色尼筛网速度比较:Python vs Julia

                  相关文章

                  <small id='kkZPX'></small><noframes id='kkZPX'>

                • <tfoot id='kkZPX'></tfoot>
                  1. <i id='kkZPX'><tr id='kkZPX'><dt id='kkZPX'><q id='kkZPX'><span id='kkZPX'><b id='kkZPX'><form id='kkZPX'><ins id='kkZPX'></ins><ul id='kkZPX'></ul><sub id='kkZPX'></sub></form><legend id='kkZPX'></legend><bdo id='kkZPX'><pre id='kkZPX'><center id='kkZPX'></center></pre></bdo></b><th id='kkZPX'></th></span></q></dt></tr></i><div id='kkZPX'><tfoot id='kkZPX'></tfoot><dl id='kkZPX'><fieldset id='kkZPX'></fieldset></dl></div>

                  2. <legend id='kkZPX'><style id='kkZPX'><dir id='kkZPX'><q id='kkZPX'></q></dir></style></legend>

                      <bdo id='kkZPX'></bdo><ul id='kkZPX'></ul>