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

Function ones_like

tensorflow/python/ops/array_ops.py:2459–2485  ·  view source on GitHub ↗

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

(tensor, dtype=None, name=None, optimize=True)

Source from the content-addressed store, hash-verified

2457@tf_export(v1=["ones_like"])
2458@dispatch.add_dispatch_support
2459def ones_like(tensor, dtype=None, name=None, optimize=True):
2460 """Creates a tensor with all elements set to 1.
2461
2462 Given a single tensor (`tensor`), this operation returns a tensor of the same
2463 type and shape as `tensor` with all elements set to 1. Optionally, you can
2464 specify a new type (`dtype`) for the returned tensor.
2465
2466 For example:
2467
2468 ```python
2469 tensor = tf.constant([[1, 2, 3], [4, 5, 6]])
2470 tf.ones_like(tensor) # [[1, 1, 1], [1, 1, 1]]
2471 ```
2472
2473 Args:
2474 tensor: A `Tensor`.
2475 dtype: A type for the returned `Tensor`. Must be `float32`, `float64`,
2476 `int8`, `uint8`, `int16`, `uint16`, `int32`, `int64`, `complex64`,
2477 `complex128` or `bool`.
2478 name: A name for the operation (optional).
2479 optimize: if true, attempt to statically determine the shape of 'tensor' and
2480 encode it as a constant.
2481
2482 Returns:
2483 A `Tensor` with all elements set to 1.
2484 """
2485 return ones_like_impl(tensor, dtype, name, optimize)
2486
2487
2488@tf_export("ones_like", v1=[])

Callers 1

strided_sliceFunction · 0.70

Calls 1

ones_like_implFunction · 0.85

Tested by

no test coverage detected