加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

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

发布时间:2020-12-16 23:33:27 所属栏目:Python 来源:网络整理
导读: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 la
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,如果需要,您应该可以使用它来获得外部产品.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读