From 101b68041c31c1372ca9b29a2dfee188680ad3e7 Mon Sep 17 00:00:00 2001 From: Chen Qian Date: Fri, 22 Jan 2021 10:51:14 -0800 Subject: [PATCH] #PRIVATE_TF_API_USAGE_CLEANUP Remove the usage of gather_non_trainable_weights. There is no reference to this method, so we just delete the method. PiperOrigin-RevId: 353274439 Change-Id: I876eac533fd6a68912900118b4159651741e7978 --- tensorflow/python/keras/utils/layer_utils.py | 32 ------------------- .../python/training/tracking/layer_utils.py | 32 ------------------- 2 files changed, 64 deletions(-) diff --git a/tensorflow/python/keras/utils/layer_utils.py b/tensorflow/python/keras/utils/layer_utils.py index 458a68a0050..8722790b069 100644 --- a/tensorflow/python/keras/utils/layer_utils.py +++ b/tensorflow/python/keras/utils/layer_utils.py @@ -299,38 +299,6 @@ def gather_trainable_weights(trainable, sub_layers, extra_variables): return weights + trainable_extra_variables -def gather_non_trainable_weights(trainable, sub_layers, extra_variables): - """Lists the non-trainable weights for an object with sub-layers. - - Args: - trainable: Whether the object collecting the variables is trainable. - sub_layers: A flat list of Layer objects owned by this object, to collect - variables from. - extra_variables: Any extra variables to include. Their `.trainable` property - is used to categorize them. - - Returns: - A list of collected non-trainable weights/variables. - """ - trainable_extra_variables = [] - non_trainable_extra_variables = [] - for v in extra_variables: - if v.trainable: - trainable_extra_variables.append(v) - else: - non_trainable_extra_variables.append(v) - weights = [] - for layer in sub_layers: - weights += layer.non_trainable_weights - if not trainable: - trainable_weights = [] - for layer in sub_layers: - trainable_weights += layer.trainable_weights - return (trainable_weights + trainable_extra_variables - + weights + non_trainable_extra_variables) - return weights + non_trainable_extra_variables - - def convert_dense_weights_data_format(dense, previous_feature_map_shape, target_data_format='channels_first'): diff --git a/tensorflow/python/training/tracking/layer_utils.py b/tensorflow/python/training/tracking/layer_utils.py index c63abebd219..17fb2756c31 100644 --- a/tensorflow/python/training/tracking/layer_utils.py +++ b/tensorflow/python/training/tracking/layer_utils.py @@ -179,35 +179,3 @@ def gather_trainable_weights(trainable, sub_layers, extra_variables): trainable_extra_variables = [ v for v in extra_variables if v.trainable] return weights + trainable_extra_variables - - -def gather_non_trainable_weights(trainable, sub_layers, extra_variables): - """Lists the non-trainable weights for an object with sub-layers. - - Args: - trainable: Whether the object collecting the variables is trainable. - sub_layers: A flat list of Layer objects owned by this object, to collect - variables from. - extra_variables: Any extra variables to include. Their `.trainable` property - is used to categorize them. - - Returns: - A list of collected non-trainable weights/variables. - """ - trainable_extra_variables = [] - non_trainable_extra_variables = [] - for v in extra_variables: - if v.trainable: - trainable_extra_variables.append(v) - else: - non_trainable_extra_variables.append(v) - weights = [] - for layer in sub_layers: - weights += layer.non_trainable_weights - if not trainable: - trainable_weights = [] - for layer in sub_layers: - trainable_weights += layer.trainable_weights - return (trainable_weights + trainable_extra_variables - + weights + non_trainable_extra_variables) - return weights + non_trainable_extra_variables