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

Function ones_like

tensorflow/python/keras/backend.py:1400–1422  ·  view source on GitHub ↗

Instantiates an all-ones variable of the same shape as another tensor. Arguments: x: Keras variable or tensor. dtype: String, dtype of returned Keras variable. None uses the dtype of x. name: String, name for the variable to create. Returns: A Keras variable

(x, dtype=None, name=None)

Source from the content-addressed store, hash-verified

1398
1399@keras_export('keras.backend.ones_like')
1400def ones_like(x, dtype=None, name=None):
1401 """Instantiates an all-ones variable of the same shape as another tensor.
1402
1403 Arguments:
1404 x: Keras variable or tensor.
1405 dtype: String, dtype of returned Keras variable.
1406 None uses the dtype of x.
1407 name: String, name for the variable to create.
1408
1409 Returns:
1410 A Keras variable with the shape of x filled with ones.
1411
1412 Example:
1413 ```python
1414 >>> from keras import backend as K
1415 >>> kvar = K.variable(np.random.random((2,3)))
1416 >>> kvar_ones = K.ones_like(kvar)
1417 >>> K.eval(kvar_ones)
1418 array([[ 1., 1., 1.],
1419 [ 1., 1., 1.]], dtype=float32)
1420 ```
1421 """
1422 return array_ops.ones_like(x, dtype=dtype, name=name)
1423
1424
1425def identity(x, name=None):

Callers 1

batch_normalizationFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected