张量繁殖
我有两个大小
a< tf.tensor'sequent_12/my_layer_56/add:0'shape =(?,300,2)dtype = float32> gt;
和 b< tf.tensor'input_82:0'shape =(?,2,2)dtype = float32> gt;
现在,我想从通常的矩阵行列产品的意义上乘以它们以获得
大小的A * B(?,300,2),因此我只能在第二和第三维中使用矩阵产品。我该如何实现?
我尝试使用具有不同轴规范的TF.Tensordot,但到目前为止尚未工作。例如,我尝试了
tf.tensordot(a,b,axes = [[2],[0]]),
但这会产生以下形式的张
量2,2)dtype = float32>
I have two tensors of size
A <tf.Tensor 'sequential_12/my_layer_56/add:0' shape=(?, 300, 2) dtype=float32>
and
B <tf.Tensor 'input_82:0' shape=(?, 2, 2) dtype=float32>
Now, I would like to multiply them in the sense of the usual matrix row-column product to obtain
A * B of size (?, 300, 2), so I would be doing the matrix product only over the second and third dimension. How can I achieve this?
I tried to use tf.tensordot with different axes specifications, but it did not work so far. For example I tried
tf.tensordot(A,B,axes=[[2], [0]])
but this produces a tensor of the following form
<tf.Tensor 'Tensordot_10:0' shape=(?, 300, 2, 2) dtype=float32>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许尝试
tf.matmul
:Maybe try
tf.matmul
: