mirror of
https://github.com/wassname/keras-contrib.git
synced 2026-08-14 12:30:09 +08:00
Made indepent of backend. Now only checks channel priority
(as suggested by @arodiss)
This commit is contained in:
@@ -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:])
|
||||
|
||||
Reference in New Issue
Block a user