Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow 矩阵乘法,但用min()之和代替乘积之和_Tensorflow_Math_Matrix_Linear Algebra_Tensorflow.js - Fatal编程技术网

Tensorflow 矩阵乘法,但用min()之和代替乘积之和

Tensorflow 矩阵乘法,但用min()之和代替乘积之和,tensorflow,math,matrix,linear-algebra,tensorflow.js,Tensorflow,Math,Matrix,Linear Algebra,Tensorflow.js,我正在寻找一系列矩阵运算,以实现以下目标: 0 0 0 0 0 4 4 4 0 4 12 10 0 4 10 13 例如,给出了输入矩阵 0 0 0 0 1 1 1 1 2 2 4 4 3 0 5 5 有什么批量/优化的想法吗?以下是如何做到这一点: 常数a=tf.tensor2d( [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 4, 4], [3, 0, 5, 5]]); 常数b=a.转置(); 常数m=a.dims(-1)。最小值(b); 常数结果=m.sum(

我正在寻找一系列矩阵运算,以实现以下目标:

0 0 0 0 0 4 4 4 0 4 12 10 0 4 10 13 例如,给出了输入矩阵

0 0 0 0 1 1 1 1 2 2 4 4 3 0 5 5
有什么批量/优化的想法吗?

以下是如何做到这一点:

常数a=tf.tensor2d(
[[0, 0, 0, 0],
[1, 1, 1, 1],
[2, 2, 4, 4],
[3, 0, 5, 5]]);
常数b=a.转置();
常数m=a.dims(-1)。最小值(b);
常数结果=m.sum(1);
result.print();
输出:

张量 [[0, 0, 0 , 0 ], [0, 4, 4 , 3 ], [0, 4, 12, 10], [0, 3, 10, 13]]"
在您给出的示例中,矩阵B在哪里?@scai“其中B是A的转置。”哇!非常感谢!在2881x2980形状上使用此代码时,TensorFlowJS抛出以下错误:错误:请求的纹理大小[193027x128140]大于此浏览器/GPU上的WebGL最大值[16384x16384]。在e.acquireTexture(tf core.esm.js?45ef:17)在e.uploadToGPU(tf core.esm.js?45ef:17)在e.compileAndRun(tf core.esm.js?45ef:17)在e.compileAndRun(tf core.esm.js?45ef:17)在e.acquireTexture(tf core.esm.js?45ef:17)在e.ENV.engine.runKernel(tf core.esm.js?45ef:17)有任何批处理/优化的想法吗?@Vinzentz问题是这个解决方案创建了一个中间的
nxnxn
张量,因此它确实需要大量内存。我不确定是否有其他好的方法来做同样的事情,但使用这种方法,你唯一能做的就是真正减少批处理大小。。。
Error: Requested texture size [193027x128140] greater than WebGL maximum on this browser / GPU [16384x16384].
    at validateTextureSize (tf-core.esm.js?45ef:17)
    at createAndConfigureTexture (tf-core.esm.js?45ef:17)
    at createFloat32MatrixTexture (tf-core.esm.js?45ef:17)
    at e.createFloat32MatrixTexture (tf-core.esm.js?45ef:17)
    at e.acquireTexture (tf-core.esm.js?45ef:17)
    at e.acquireTexture (tf-core.esm.js?45ef:17)
    at e.uploadToGPU (tf-core.esm.js?45ef:17)
    at e.compileAndRun (tf-core.esm.js?45ef:17)
    at e.minimum (tf-core.esm.js?45ef:17)
    at ENV.engine.runKernel.$a (tf-core.esm.js?45ef:17)