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

Function eye

tensorflow/python/keras/backend.py:1344–1369  ·  view source on GitHub ↗

Instantiate an identity matrix and returns it. Arguments: size: Integer, number of rows/columns. dtype: String, data type of returned Keras variable. name: String, name of returned Keras variable. Returns: A Keras variable, an identity matrix. Example: ```python

(size, dtype=None, name=None)

Source from the content-addressed store, hash-verified

1342
1343@keras_export('keras.backend.eye')
1344def eye(size, dtype=None, name=None):
1345 """Instantiate an identity matrix and returns it.
1346
1347 Arguments:
1348 size: Integer, number of rows/columns.
1349 dtype: String, data type of returned Keras variable.
1350 name: String, name of returned Keras variable.
1351
1352 Returns:
1353 A Keras variable, an identity matrix.
1354
1355 Example:
1356 ```python
1357 >>> from keras import backend as K
1358 >>> kvar = K.eye(3)
1359 >>> K.eval(kvar)
1360 array([[ 1., 0., 0.],
1361 [ 0., 1., 0.],
1362 [ 0., 0., 1.]], dtype=float32)
1363 ```
1364
1365 """
1366 if dtype is None:
1367 dtype = floatx()
1368 tf_dtype = dtypes_module.as_dtype(dtype)
1369 return variable(linalg_ops.eye(size, dtype=tf_dtype), dtype, name)
1370
1371
1372@keras_export('keras.backend.zeros_like')

Callers 2

ComputeAsyncMethod · 0.50
ComputeAsyncMethod · 0.50

Calls 2

floatxFunction · 0.85
variableFunction · 0.70

Tested by

no test coverage detected