aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/layers
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-06-22 10:35:02 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-06-22 10:38:16 -0700
commit55e56a79d0650fe92a6a81751c0ee5597adf8fe2 (patch)
treed0b5f7c566d4be342c545d6db9ac8ef9842308ed /tensorflow/contrib/layers
parent8dd483f9c5387e8c398c3bed1b4cff4a28634b80 (diff)
For separable_conv2d, add an optional pointwise_initializer parameter so that the pointwise weights can be initialized differently from the depthwise weights.
PiperOrigin-RevId: 201705897
Diffstat (limited to 'tensorflow/contrib/layers')
-rw-r--r--tensorflow/contrib/layers/python/layers/layers.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tensorflow/contrib/layers/python/layers/layers.py b/tensorflow/contrib/layers/python/layers/layers.py
index b6d63c9640..beeabd6b65 100644
--- a/tensorflow/contrib/layers/python/layers/layers.py
+++ b/tensorflow/contrib/layers/python/layers/layers.py
@@ -2664,6 +2664,7 @@ def separable_convolution2d(
normalizer_fn=None,
normalizer_params=None,
weights_initializer=initializers.xavier_initializer(),
+ pointwise_initializer=None,
weights_regularizer=None,
biases_initializer=init_ops.zeros_initializer(),
biases_regularizer=None,
@@ -2705,7 +2706,9 @@ def separable_convolution2d(
`biases_regularizer` are ignored and `biases` are not created nor added.
default set to None for no normalizer function
normalizer_params: Normalization function parameters.
- weights_initializer: An initializer for the weights.
+ weights_initializer: An initializer for the depthwise weights.
+ pointwise_initializer: An initializer for the pointwise weights.
+ default set to None, means use weights_initializer.
weights_regularizer: Optional regularizer for the weights.
biases_initializer: An initializer for the biases. If None skip biases.
biases_regularizer: Optional regularizer for the biases.
@@ -2737,6 +2740,9 @@ def separable_convolution2d(
custom_getter=layer_variable_getter) as sc:
inputs = ops.convert_to_tensor(inputs)
+ if pointwise_initializer is None:
+ pointwise_initializer = weights_initializer
+
df = ('channels_first'
if data_format and data_format.startswith('NC') else 'channels_last')
if num_outputs is not None:
@@ -2752,7 +2758,7 @@ def separable_convolution2d(
depth_multiplier=depth_multiplier,
use_bias=not normalizer_fn and biases_initializer,
depthwise_initializer=weights_initializer,
- pointwise_initializer=weights_initializer,
+ pointwise_initializer=pointwise_initializer,
bias_initializer=biases_initializer,
depthwise_regularizer=weights_regularizer,
pointwise_regularizer=weights_regularizer,