mirror of
https://github.com/wassname/keras-contrib.git
synced 2026-09-12 12:32:18 +08:00
Add assertions to prevent using wrong dim ordering/backends when using depth_to_space backend methods
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user