python – TensorFlow:Hadamard产品::我如何得到这个?

前端之家收集整理的这篇文章主要介绍了python – TensorFlow:Hadamard产品::我如何得到这个?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Tensorflow具有以下功能
tf.matmul

它将两个向量相乘并产生一个标量.

但是,我需要做以下事情:

# dense dim:  (?,227)
dense_part = tf.nn.relu(some stuff here)

# softmax matrix dim: (?,227,19) or (?,19,227) or (?,227),where I 
# ....can slice the last dim down to (?,19)
softmax_matrix = tf.matmul(dense_part,softmax_weight_variable)

但是,为了通过矩阵乘法实现这一点,我无法设置softmax_weight_variable.我需要使用“Tensor Product”(也称为“Outer Product”……),但这个功能似乎没有实现.

如何在TensorFlow中实现Hadamard(元素方式)乘法和外积?

解决方法

x和y的元素乘法仅为 tf.mul(x,y).这也是 supports NumPy-style broadcasting,如果需要,您应该可以使用它来获得外部产品.
原文链接:https://www.f2er.com/python/185728.html

猜你在找的Python相关文章