API - Array 操作

A file containing functions related to array manipulation.

alphas(shape, alpha_value[, name]) Creates a tensor with all elements set to alpha_value.
alphas_like(tensor, alpha_value[, name, ...]) Creates a tensor with all elements set to alpha_value.

Tensorflow Tensor 操作

tl.alphas

tensorlayer.array_ops.alphas(shape, alpha_value, name=None)[源代码]

Creates a tensor with all elements set to alpha_value. This operation returns a tensor of type dtype with shape shape and all elements set to alpha.

参数:
  • shape (A list of integers, a tuple of integers, or a 1-D Tensor of type int32.) -- The shape of the desired tensor
  • alpha_value (float32, float64, int8, uint8, int16, uint16, int32`, int64) -- The value used to fill the resulting Tensor.
  • name (str) -- A name for the operation (optional).
返回:

返回类型:

A Tensor with all elements set to alpha.

Examples

>>> tl.alphas([2, 3], tf.int32)  # [[alpha, alpha, alpha], [alpha, alpha, alpha]]

tl.alphas_like

tensorlayer.array_ops.alphas_like(tensor, alpha_value, name=None, optimize=True)[源代码]

Creates a tensor with all elements set to alpha_value. Given a single tensor (tensor), this operation returns a tensor of the same type and shape as tensor with all elements set to alpha_value.

参数:
  • tensor (tf.Tensor) -- The Tensorflow Tensor that will be used as a template.
  • alpha_value (float32, float64, int8, uint8, int16, uint16, int32`, int64) -- The value used to fill the resulting Tensor.
  • name (str) -- A name for the operation (optional).
  • optimize (bool) -- if true, attempt to statically determine the shape of 'tensor' and encode it as a constant.
返回:

返回类型:

A Tensor with all elements set to alpha_value.

Examples

>>> tensor = tf.constant([[1, 2, 3], [4, 5, 6]])
>>> tl.alphas_like(tensor, 0.5)  # [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5]]