tf.linspace(start, stop, num, name=None)

Generates values in an interval.

A sequence of num evenly-spaced values are generated beginning at start. If num > 1, the values in the sequence increase by stop - start / num - 1, so that the last one is exactly stop.

For example:

tf.linspace(10.0, 12.0, 3, name="linspace") => [ 10.0  11.0  12.0]
  • start: A Tensor. Must be one of the following types: float32, float64. First entry in the range.
  • stop: A Tensor. Must have the same type as start. Last entry in the range.
  • num: A Tensor. Must be one of the following types: int32, int64. Number of values to generate.
  • name: A name for the operation (optional).

A Tensor. Has the same type as start. 1-D. The generated values.

tf.range(start, limit=None, delta=1, dtype=None, name='range')

Creates a sequence of numbers.

Creates a sequence of numbers that begins at start and extends by increments of delta up to but not including limit.

The dtype of the resulting tensor is inferred from the inputs unless it is provided explicitly.

Like the Python builtin range, start defaults to 0, so that range(n) = range(0, n).

For example:

# 'start' is 3
# 'limit' is 18
# 'delta' is 3
tf.range(start, limit, delta) ==> [3, 6, 9, 12, 15]

# 'start' is 3
# 'limit' is 1
# 'delta' is -0.5
tf.range(start, limit, delta) ==> [3, 2.5, 2, 1.5]

# 'limit' is 5
tf.range(limit) ==> [0, 1, 2, 3, 4]
  • start: A 0-D Tensor (scalar). Acts as first entry in the range if limit is not None; otherwise, acts as range limit and first entry defaults to 0.
  • limit: A 0-D Tensor (scalar). Upper limit of sequence, exclusive. If None, defaults to the value of start while the first entry of the range defaults to 0.
  • delta: A 0-D Tensor (scalar). Number that increments start. Defaults to 1.
  • dtype: The type of the elements of the resulting tensor.
  • name: A name for the operation. Defaults to "range".

An 1-D Tensor of type dtype.

@compatibility(numpy) Equivalent to np.arange @end_compatibility