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)
| 1398 | |
| 1399 | @keras_export('keras.backend.ones_like') |
| 1400 | def 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 | |
| 1425 | def identity(x, name=None): |
no outgoing calls
no test coverage detected