keepdims的后端参数是什么?

2024-04-18 18:09:31 发布

您现在位置:Python中文网/ 问答频道 /正文

Keras后端中有许多函数具有keepdims参数。例如

sum(x, axis=None, keepdims=False)

我找不到任何解释那意味着什么。有人能解释一下它的作用吗?在

另外,axisNone是什么意思?这和说axis = -1是一样的吗?在


Tags: 函数nonefalse参数kerassumaxiskeepdims
2条回答

您可以在deeplearning.net中找到有关theano(keras后端之一)的文档和教程

有关方法theano.tensor.sum,请参见here

theano.tensor.sum(x, axis=None, dtype=None, keepdims=False, acc_dtype=None)

axis - axis or axes along which to compute the sum

keepdims - (boolean) If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original tensor.

正如EoinS所指出的,theano函数与numpy的函数非常相似。在

这些不是keras特定的参数,而是numpy.sum参数。在

axis : None or int or tuple of ints, optional

Axis or axes along which a sum is performed. The default (axis = None) is perform a sum over all the dimensions of the input array. axis may be negative, in which case it counts from the last to the first axis.

New in version 1.7.0.

If this is a tuple of ints, a sum is performed on multiple axes, instead of a single axis or all the axes as before.

keepdims : bool, optional

If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original arr.

here is the source

相关问题 更多 >