File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
tensorflow_model_optimization/python/core/sparsity/keras Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,7 @@ py_library(
199
199
":prune" ,
200
200
":pruning_wrapper" ,
201
201
# numpy dep1,
202
+ # tensorflow dep1,
202
203
# python/keras tensorflow dep2,
203
204
# python/keras:backend tensorflow dep2,
204
205
# python/keras:saving tensorflow dep2,
Original file line number Diff line number Diff line change 17
17
import tempfile
18
18
import numpy as np
19
19
20
+ import tensorflow as tf
21
+
20
22
from tensorflow .python import keras
21
23
from tensorflow .python .keras import backend as K
22
- from tensorflow .python .keras .saving import saved_model_experimental
23
24
from tensorflow_model_optimization .python .core .sparsity .keras import prune
24
25
from tensorflow_model_optimization .python .core .sparsity .keras import pruning_wrapper
25
26
@@ -109,10 +110,10 @@ def _save_restore_keras_model(model):
109
110
110
111
def _save_restore_saved_model (model ):
111
112
tmpdir = tempfile .mkdtemp ()
112
- saved_model_experimental .export_saved_model (model , tmpdir )
113
+ tf . keras . experimental .export_saved_model (model , tmpdir )
113
114
114
115
with prune .prune_scope ():
115
- loaded_model = saved_model_experimental .load_from_saved_model (tmpdir )
116
+ loaded_model = tf . keras . experimental .load_from_saved_model (tmpdir )
116
117
117
118
loaded_model .compile (
118
119
loss = 'categorical_crossentropy' , optimizer = 'sgd' , metrics = ['accuracy' ])
You can’t perform that action at this time.
0 commit comments