Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a test for the identity, non-negative, and unit-norm constraints
  • Loading branch information
phreeza authored and tleeuwenburg committed Jul 3, 2015
commit b48e39aafd9ef413216444a6bfb97e867aa40e1c
20 changes: 20 additions & 0 deletions tests/auto/keras/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,25 @@ def test_maxnorm(self):
normed = norm_instance(self.example_array)
assert(np.all(normed.eval() < m))

def test_nonneg(self):
from keras.constraints import nonneg

normed = nonneg(self.example_array)
assert(np.all(np.min(normed.eval(),axis=1) == 0.))

def test_identity(self):
from keras.constraints import identity

normed = identity(self.example_array)
assert(np.all(normed == self.example_array))

def test_unitnorm(self):
from keras.constraints import unitnorm

normed = unitnorm(self.example_array)
self.assertAlmostEqual(
np.max(np.abs(np.sqrt(np.sum(normed.eval()**2,axis=1))-1.))
,0.)

if __name__ == '__main__':
unittest.main()