python dot函数功能_机器学习笔记(七)--理解batch_dot函数

def batch_dot(x, y, axes=None):

"""Batchwise dot product.

`batch_dot` is used to compute dot product of `x` and `y` when

`x` and `y` are data in batches, i.e. in a shape of

`(batch_size, :)`.

`batch_dot` results in a tensor or variable with less dimensions

than the input. If the number of dimensions is reduced to 1,

we use `expand_dims` to make sure that ndim is at least 2.

这个函数是用于计算批次数据‘x’和‘y'的内积,两个数据的batch_size必须相同。

函数的输出张量的维度数量会少于输入的维度数量和。如果输出的维度数量减少到1,就会使用

’expand_dim‘函数来确保维度数量至少为2。

# Arguments

x: Keras tensor or variable with `ndim >= 2`. 维度数量 >= 2

y: Keras tensor or variable with `ndim >= 2`. 维度数量 >= 2

axes: int or tuple(int, int). Target dimensions to be reduced.

要减少的目标维度。理论上从0开始(即shape首位),但batch_size是忽略的,故从1开始。若是一

个整数,则表示两个输入的shape的同一位。若是一个tuple或list,则分别指向不同位置。

注意:无论axes是那种类型,指向的两个位置上的数值必须一致。

# Returns

A tensor with shape equal to the concatenation of `x`'s shape

(less the dimension that was summed over) and `y`'s shape

(less the batch dimension and the dimension that was summed over).

If the final rank is 1, we reshape it to `(batch_size, 1)`.

"""

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值