|
15 | 15 | """Contains definitions of MobileNet Networks."""
|
16 | 16 |
|
17 | 17 | import dataclasses
|
18 |
| -from typing import Any |
| 18 | +from typing import Any, Union |
19 | 19 |
|
20 | 20 | # Import libraries
|
21 | 21 |
|
@@ -92,9 +92,9 @@ class BlockSpec(hyperparams.Config):
|
92 | 92 | use_normalization: bool = True
|
93 | 93 | activation: str = 'relu6'
|
94 | 94 | # Used for block type InvertedResConv.
|
95 |
| - expand_ratio: float | None = 6.0 |
| 95 | + expand_ratio: Union[float, None] = 6.0 |
96 | 96 | # Used for block type InvertedResConv with SE.
|
97 |
| - se_ratio: float | None = None |
| 97 | + se_ratio: Union[float, None] = None |
98 | 98 | use_depthwise: bool = True
|
99 | 99 | use_residual: bool = True
|
100 | 100 | is_output: bool = True
|
@@ -145,8 +145,8 @@ def __init__(
|
145 | 145 | use_explicit_padding: bool = False,
|
146 | 146 | activation: str = 'relu6',
|
147 | 147 | kernel_initializer: str = 'VarianceScaling',
|
148 |
| - kernel_regularizer: tf_keras.regularizers.Regularizer | None = None, |
149 |
| - bias_regularizer: tf_keras.regularizers.Regularizer | None = None, |
| 148 | + kernel_regularizer: Union[tf_keras.regularizers.Regularizer, None] = None, |
| 149 | + bias_regularizer: Union[tf_keras.regularizers.Regularizer, None] = None, |
150 | 150 | use_normalization: bool = True,
|
151 | 151 | use_sync_bn: bool = False,
|
152 | 152 | norm_momentum: float = 0.99,
|
@@ -1230,10 +1230,10 @@ def __init__(
|
1230 | 1230 | norm_momentum: float = 0.99,
|
1231 | 1231 | norm_epsilon: float = 0.001,
|
1232 | 1232 | kernel_initializer: str = 'VarianceScaling',
|
1233 |
| - kernel_regularizer: tf_keras.regularizers.Regularizer | None = None, |
1234 |
| - bias_regularizer: tf_keras.regularizers.Regularizer | None = None, |
| 1233 | + kernel_regularizer: Union[tf_keras.regularizers.Regularizer, None] = None, |
| 1234 | + bias_regularizer: Union[tf_keras.regularizers.Regularizer, None] = None, |
1235 | 1235 | # The followings should be kept the same most of the times.
|
1236 |
| - output_stride: int | None = None, |
| 1236 | + output_stride: Union[int, None] = None, |
1237 | 1237 | min_depth: int = 8,
|
1238 | 1238 | # divisible is not used in MobileNetV1.
|
1239 | 1239 | divisible_by: int = 8,
|
@@ -1595,7 +1595,7 @@ def build_mobilenet(
|
1595 | 1595 | input_specs: tf_keras.layers.InputSpec,
|
1596 | 1596 | backbone_config: hyperparams.Config,
|
1597 | 1597 | norm_activation_config: hyperparams.Config,
|
1598 |
| - l2_regularizer: tf_keras.regularizers.Regularizer | None = None, |
| 1598 | + l2_regularizer: Union[tf_keras.regularizers.Regularizer, None] = None, |
1599 | 1599 | ) -> tf_keras.Model:
|
1600 | 1600 | """Builds MobileNet backbone from a config."""
|
1601 | 1601 | backbone_type = backbone_config.type
|
|
0 commit comments