Skip to content

Commit c35fc4c

Browse files
Add fix for the case that prune wrapper is added but no layer is prunable.
PiperOrigin-RevId: 358303341
1 parent e373224 commit c35fc4c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tensorflow_model_optimization/python/core/sparsity/keras/pruning_callbacks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def __init__(self):
6464
def on_train_begin(self, logs=None):
6565
# Collect all the prunable layers in the model.
6666
self.prunable_layers = _collect_prunable_layers(self.model)
67+
if not self.prunable_layers:
68+
return
6769
# If the model is newly created/initialized, set the 'pruning_step' to 0.
6870
# If the model is saved and then restored, do nothing.
6971
if self.prunable_layers[0].pruning_step == -1:

0 commit comments

Comments
 (0)