Add TFDWConv() depth_multiplier (#7858)
Enabled grouped non c1 == c2 convolutions in TF YOLOv5 models.
This commit is contained in:
1 parent
91c82d8f92
commit
1b8e70f037
1 file changed
+2
-1
+2
-1
@@ -91,9 +91,10 @@ class TFDWConv(keras.layers.Layer):
|
|||||||
def __init__(self, c1, c2, k=1, s=1, p=None, act=True, w=None):
|
def __init__(self, c1, c2, k=1, s=1, p=None, act=True, w=None):
|
||||||
# ch_in, ch_out, weights, kernel, stride, padding, groups
|
# ch_in, ch_out, weights, kernel, stride, padding, groups
|
||||||
super().__init__()
|
super().__init__()
|
||||||
assert c1 == c2, f'TFDWConv() input={c1} must equal output={c2} channels'
|
assert c2 % c1 == 0, f'TFDWConv() output={c2} must be a multiple of input={c1} channels'
|
||||||
conv = keras.layers.DepthwiseConv2D(
|
conv = keras.layers.DepthwiseConv2D(
|
||||||
kernel_size=k,
|
kernel_size=k,
|
||||||
|
depth_multiplier=c2 // c1,
|
||||||
strides=s,
|
strides=s,
|
||||||
padding='SAME' if s == 1 else 'VALID',
|
padding='SAME' if s == 1 else 'VALID',
|
||||||
use_bias=not hasattr(w, 'bn'),
|
use_bias=not hasattr(w, 'bn'),
|
||||||
|
|||||||
Reference in new issue
Block a user