阅读(2316) (1)

TensorFlow函数:tf.ones

2017-11-06 18:19:20 更新
tf.ones 函数
ones(
    shape,
    dtype=tf.float32,
    name=None
)

定义于:tensorflow/python/ops/array_ops.py.

请参阅指南:生成常量,序列和随机值>常量值张量

创建一个将所有元素都设置为1的张量.

这个操作返回一个 dtype 类型的张量,并且形状为 shape,所有的元素都被设置为1.

例如:

tf.ones([2, 3], tf.int32) ==> [[1, 1, 1], [1, 1, 1]]

参数:

  • shape:整数的列表,整数的元组或 int32 类型的一维张量.
  • dtype:生成的张量中元素的类型.
  • name:操作的名称(可选).

返回值:

该函数返回所有元素都设置为1的张量.