MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / arange

Function arange

tensorflow/python/keras/backend.py:2849–2883  ·  view source on GitHub ↗

Creates a 1D tensor containing a sequence of integers. The function arguments use the same convention as Theano's arange: if only one argument is provided, it is in fact the "stop" argument and "start" is 0. The default type of the returned tensor is `'int32'` to match TensorFlow's defau

(start, stop=None, step=1, dtype='int32')

Source from the content-addressed store, hash-verified

2847
2848@keras_export('keras.backend.arange')
2849def arange(start, stop=None, step=1, dtype='int32'):
2850 """Creates a 1D tensor containing a sequence of integers.
2851
2852 The function arguments use the same convention as
2853 Theano's arange: if only one argument is provided,
2854 it is in fact the "stop" argument and "start" is 0.
2855
2856 The default type of the returned tensor is `'int32'` to
2857 match TensorFlow's default.
2858
2859 Arguments:
2860 start: Start value.
2861 stop: Stop value.
2862 step: Difference between two successive values.
2863 dtype: Integer dtype to use.
2864
2865 Returns:
2866 An integer tensor.
2867
2868 Example:
2869 ```python
2870 >>> tf.keras.backend.arange(start=0, stop=10, step=1.5)
2871 <tf.Tensor: id=96, shape=(7,), dtype=float32,
2872 numpy=array([0. , 1.5, 3. , 4.5, 6. , 7.5, 9. ], dtype=float32)>
2873
2874 ```
2875
2876 """
2877 # Match the behavior of numpy and Theano by returning an empty sequence.
2878 if stop is None and start < 0:
2879 start = 0
2880 result = math_ops.range(start, limit=stop, delta=step, name='arange')
2881 if dtype != 'int32':
2882 result = cast(result, dtype)
2883 return result
2884
2885
2886@keras_export('keras.backend.tile')

Callers

nothing calls this directly

Calls 2

castFunction · 0.70
rangeMethod · 0.45

Tested by

no test coverage detected