Skip to content

Commit

Permalink
add reset_uids to cntk backend (keras-team#12300)
Browse files Browse the repository at this point in the history
* add cntk reset_uids

* remove empty_dict return on reset_uids cntk

* add newline
  • Loading branch information
Ryan-Qiyu-Jiang authored and fchollet committed Feb 24, 2019
1 parent 71aadf5 commit 780b74d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion keras/backend/cntk_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2731,7 +2731,8 @@ def backward(self, state, root_gradients):


def reset_uids():
raise NotImplementedError
global _UID_PREFIXES
_UID_PREFIXES = defaultdict(int)


def to_dense(tensor):
Expand Down
7 changes: 7 additions & 0 deletions tests/keras/backend/backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,13 @@ def test_elementwise_operations(self):
check_two_tensor_operation('maximum', (4, 2), (4, 2), WITH_NP)
check_two_tensor_operation('minimum', (4, 2), (4, 2), WITH_NP)

# assumes first uid will always be the same
def test_reset_uids(self):
first = K.get_uid()
K.get_uid()
K.reset_uids()
assert K.get_uid() == first

@pytest.mark.skipif(K.backend() == 'cntk', reason='cntk does not support '
'cumsum and cumprod yet')
def test_cumsum_cumprod(self):
Expand Down

0 comments on commit 780b74d

Please sign in to comment.