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

Function zeros_like_v2

tensorflow/python/ops/array_ops.py:2387–2423  ·  view source on GitHub ↗

Creates a tensor with all elements set to zero. Given a single tensor (`tensor`), this operation returns a tensor of the same type and shape as `tensor` with all elements set to zero. Optionally, you can use `dtype` to specify a new type for the returned tensor. For example: ```python

(
    input,  # pylint: disable=redefined-builtin
    dtype=None,
    name=None)

Source from the content-addressed store, hash-verified

2385@tf_export("zeros_like", v1=[])
2386@dispatch.add_dispatch_support
2387def zeros_like_v2(
2388 input, # pylint: disable=redefined-builtin
2389 dtype=None,
2390 name=None):
2391 """Creates a tensor with all elements set to zero.
2392
2393 Given a single tensor (`tensor`), this operation returns a tensor of the
2394 same type and shape as `tensor` with all elements set to zero. Optionally,
2395 you can use `dtype` to specify a new type for the returned tensor.
2396
2397 For example:
2398
2399 ```python
2400 tensor = tf.constant([[1, 2, 3], [4, 5, 6]])
2401 tf.zeros_like(tensor) # [[0, 0, 0], [0, 0, 0]] with dtype=int32
2402
2403 If dtype of input `tensor` is `float32`, then the output is also of `float32`
2404 tensor = tf.constant([[1.0, 2.0, 3.0], [4, 5, 6]])
2405 tf.zeros_like(tensor) # [[0., 0., 0.], [0., 0., 0.]] with dtype=floa32
2406
2407 If you want to specify desired dtype of output `tensor`, then specify it in
2408 the op tensor = tf.constant([[1.0, 2.0, 3.0], [4, 5, 6]])
2409 tf.zeros_like(tensor,dtype=tf.int32) # [[0, 0, 0], [0, 0, 0]] with
2410 dtype=int32
2411 ```
2412
2413 Args:
2414 input: A `Tensor`.
2415 dtype: A type for the returned `Tensor`. Must be `float16`, `float32`,
2416 `float64`, `int8`, `uint8`, `int16`, `uint16`, `int32`, `int64`,
2417 `complex64`, `complex128`, `bool` or `string`.
2418 name: A name for the operation (optional).
2419
2420 Returns:
2421 A `Tensor` with all elements set to zero.
2422 """
2423 return zeros_like_impl(input, dtype, name, optimize=True)
2424
2425
2426def zeros_like_impl(tensor, dtype, name, optimize=True):

Callers

nothing calls this directly

Calls 1

zeros_like_implFunction · 0.85

Tested by

no test coverage detected