Skip to content

Commit c398c08

Browse files
EderSantanafchollet
authored andcommitted
add eye to backened (keras-team#2407)
1 parent 5ab48ac commit c398c08

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

keras/backend/tensorflow_backend.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ def ones(shape, dtype=_FLOATX, name=None):
136136
return variable(np.ones(shape), dtype, name)
137137

138138

139+
def eye(size, dtype=_FLOATX, name=None):
140+
'''Instantiate an identity matrix.
141+
'''
142+
return variable(np.eye(size), dtype, name)
143+
144+
139145
def zeros_like(x, name=None):
140146
'''Instantiates an all-zeros tensor
141147
of the same shape as another tensor.

keras/backend/theano_backend.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ def ones(shape, dtype=_FLOATX, name=None):
7979
return variable(np.ones(shape), dtype, name)
8080

8181

82+
def eye(size, dtype=_FLOATX, name=None):
83+
'''Instantiate an identity matrix.
84+
'''
85+
return variable(np.eye(size), dtype, name)
86+
87+
8288
def ones_like(x):
8389
return T.ones_like(x)
8490

0 commit comments

Comments
 (0)