API - Array Operations

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 Operations

tl.alphas

tensorlayer.array_ops.alphas(shape, alpha_value, name=None)[source]

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.

Parameters
  • 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).

Returns

Return type

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)[source]

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.

Parameters
  • 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.

Returns

Return type

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]]