-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlayer.py
32 lines (24 loc) · 878 Bytes
/
layer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import tensorflow as tf
from tensorflow.keras.layers import Conv2D
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import BatchNormalization
from tensorflow.keras.layers.experimental import SyncBatchNormalization
from tensorflow.keras.initializers import Constant
BatchNorm_DICT = {
"bn": BatchNormalization,
"syncbn": SyncBatchNormalization}
def _conv2d(**custom_kwargs):
def _func(*args, **kwargs):
kwargs.update(**custom_kwargs)
return Conv2D(*args, **kwargs)
return _func
def _batchnorm(norm='bn', **custom_kwargs):
def _func(*args, **kwargs):
kwargs.update(**custom_kwargs)
return BatchNorm_DICT[norm](*args, **kwargs)
return _func
def _dense(**custom_kwargs):
def _func(*args, **kwargs):
kwargs.update(**custom_kwargs)
return Dense(*args, **kwargs)
return _func