Add assertions to prevent using wrong dim ordering/backends when using depth_to_space backend methods

This commit is contained in:
Somshubra Majumdar
2017-02-27 23:00:52 -06:00
parent 1986348465
commit 3634ca6bfc
3 changed files with 7 additions and 3 deletions
@@ -103,6 +103,8 @@ def extract_image_patches(X, ksizes, ssizes, border_mode="same", dim_ordering="t
def depth_to_space(input, scale):
''' Uses phase shift algorithm to convert channels/depth for spatial resolution '''
assert K.image_dim_ordering() == 'tf', 'depth_to_scale backend function can only be used with "tf" dim ' \
'ordering when using tensorflow backend'
return tf.depth_to_space(input, scale)
+2
View File
@@ -121,6 +121,8 @@ def extract_image_patches(X, ksizes, strides, border_mode="valid", dim_ordering=
def depth_to_space(input, scale):
''' Uses phase shift algorithm to convert channels/depth for spatial resolution '''
assert K.image_dim_ordering() == 'th', 'depth_to_scale backend function can only be used with "th" dim ' \
'ordering when using theano backend'
b, k, row, col = input.shape
output_shape = (b, input._keras_shape[1] // (scale ** 2), row * scale, col * scale)
+3 -3
View File
@@ -1,10 +1,10 @@
# Configuration of py.test
[pytest]
addopts=-v
-n 2
#-n 2
--durations=10
--cov-report term-missing
--cov=keras
#--cov-report term-missing
#--cov=keras
# Do not run tests in the build folder
norecursedirs= build