前回の微調整段階で保存されたチェックポイントをモデルに読み込みます。プルーニング率の値を大きくして、スパース (疎) モデルを生成します。このスパース モデルの微調整を続けます。スパース度が目的の値に達するまで、このプルーニングと微調整のループを数回繰り返します。
model.load_weights("model_sparse_0.2")
input_shape = [28, 28, 1]
input_spec = tf.TensorSpec((1, *input_shape), tf.float32)
runner = IterativePruningRunner(model, input_spec)
sparse_model = runner.prune(ratio=0.5)