Skip to content

Commit

Permalink
fixed div bug
Browse files Browse the repository at this point in the history
  • Loading branch information
0x00b1 committed Jul 18, 2017
1 parent 059aca8 commit 1edba79
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions keras_resnet/blocks/_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ def _shortcut(a, b):
b_shape = keras.backend.int_shape(b)

if keras.backend.image_data_format() == "channels_last":
x = int(round(a_shape[1] // b_shape[1]))
y = int(round(a_shape[2] // b_shape[2]))
x = int(round(a_shape[1] / b_shape[1]))
y = int(round(a_shape[2] / b_shape[2]))

if x > 1 or y > 1 or not a_shape[3] == b_shape[3]:
a = keras.layers.Conv2D(b_shape[3], (1, 1), strides=(x, y), padding="same", **parameters)(a)

a = keras.layers.BatchNormalization(axis=3)(a)
else:
x = int(round(a_shape[2] // b_shape[2]))
y = int(round(a_shape[3] // b_shape[3]))
x = int(round(a_shape[2] / b_shape[2]))
y = int(round(a_shape[3] / b_shape[3]))

if x > 1 or y > 1 or not a_shape[1] == b_shape[1]:
a = keras.layers.Conv2D(b_shape[1], (1, 1), strides=(x, y), padding="same", **parameters)(a)
Expand Down
8 changes: 4 additions & 4 deletions keras_resnet/blocks/_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ def _shortcut(a, b):
b_shape = keras.backend.int_shape(b)

if keras.backend.image_data_format() == "channels_last":
x = int(round(a_shape[1] // b_shape[1]))
y = int(round(a_shape[2] // b_shape[2]))
x = int(round(a_shape[1] / b_shape[1]))
y = int(round(a_shape[2] / b_shape[2]))

if x > 1 or y > 1 or not a_shape[3] == b_shape[3]:
a = keras.layers.Conv2D(b_shape[3], (1, 1), strides=(x, y), padding="same", **parameters)(a)

a = keras.layers.BatchNormalization(axis=3)(a)
else:
x = int(round(a_shape[2] // b_shape[2]))
y = int(round(a_shape[3] // b_shape[3]))
x = int(round(a_shape[2] / b_shape[2]))
y = int(round(a_shape[3] / b_shape[3]))

if x > 1 or y > 1 or not a_shape[1] == b_shape[1]:
a = keras.layers.Conv2D(b_shape[1], (1, 1), strides=(x, y), padding="same", **parameters)(a)
Expand Down
8 changes: 4 additions & 4 deletions keras_resnet/blocks/_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ def _shortcut(a, b):
b_shape = keras.backend.int_shape(b)

if keras.backend.image_data_format() == "channels_last":
x = int(round(a_shape[1] // b_shape[1]))
y = int(round(a_shape[2] // b_shape[2]))
x = int(round(a_shape[1] / b_shape[1]))
y = int(round(a_shape[2] / b_shape[2]))

if x > 1 or y > 1 or not a_shape[3] == b_shape[3]:
a = keras.layers.Conv3D(b_shape[3], (1, 1, 1), strides=(x, y), padding="same", **parameters)(a)

a = keras.layers.BatchNormalization(axis=3)(a)
else:
x = int(round(a_shape[2] // b_shape[2]))
y = int(round(a_shape[3] // b_shape[3]))
x = int(round(a_shape[2] / b_shape[2]))
y = int(round(a_shape[3] / b_shape[3]))

if x > 1 or y > 1 or not a_shape[1] == b_shape[1]:
a = keras.layers.Conv3D(b_shape[1], (1, 1, 1), strides=(x, y), padding="same", **parameters)(a)
Expand Down
8 changes: 4 additions & 4 deletions keras_resnet/blocks/_time_distributed_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ def _shortcut(a, b):
b_shape = keras.backend.int_shape(b)[1:]

if keras.backend.image_data_format() == "channels_last":
x = int(round(a_shape[1] // b_shape[1]))
y = int(round(a_shape[2] // b_shape[2]))
x = int(round(a_shape[1] / b_shape[1]))
y = int(round(a_shape[2] / b_shape[2]))

if x > 1 or y > 1 or not a_shape[3] == b_shape[3]:
a = keras.layers.TimeDistributed(keras.layers.Conv2D(b_shape[3], (1, 1), strides=(x, y), padding="same", **parameters))(a)

a = keras.layers.TimeDistributed(keras.layers.BatchNormalization(axis=3))(a)
else:
x = int(round(a_shape[2] // b_shape[2]))
y = int(round(a_shape[3] // b_shape[3]))
x = int(round(a_shape[2] / b_shape[2]))
y = int(round(a_shape[3] / b_shape[3]))

if x > 1 or y > 1 or not a_shape[1] == b_shape[1]:
a = keras.layers.TimeDistributed(keras.layers.Conv2D(b_shape[1], (1, 1), strides=(x, y), padding="same", **parameters))(a)
Expand Down

0 comments on commit 1edba79

Please sign in to comment.