Made indepent of backend. Now only checks channel priority

(as suggested by @arodiss)
This commit is contained in:
lameeus
2017-10-25 13:45:52 +02:00
parent 3d710d4984
commit ececa1b7af
2 changed files with 4 additions and 8 deletions
@@ -63,14 +63,12 @@ class DeadReluDetector(Callback):
act_len = len(shape_act)
# should work for both Conv and Flat
if K.backend() == 'tensorflow':
if K.image_data_format() == 'channels_last':
# features in last axis
axis_filter = -1
elif K.backend() == 'theano':
else:
# features before the convolution axis, for weight_len the input and output have to be subtracted
axis_filter = -1 - (weight_len - 2)
else:
raise ValueError('Unknown backend: {}'.format(K.backend()))
total_featuremaps = shape_act[axis_filter]
@@ -96,12 +96,10 @@ def test_DeadDeadReluDetector_conv():
n_samples = 9
# (5, 5) kernel, 4 input featuremaps and 10 output featuremaps
if K.backend() == 'tensorflow':
if K.image_data_format() == 'channels_last':
input_shape = (n_samples, 5, 5, 4)
elif K.backend() == 'theano':
input_shape = (n_samples, 4, 5, 5)
else:
raise ValueError('Unknown backend: {}'.format(K.backend()))
input_shape = (n_samples, 4, 5, 5)
# ignore batch size
input_shape_conv = tuple(input_shape[1:])