In [8]:
%%bash
which summarize_graph
In [10]:
%%bash
## TODO: /root/models/linear/cpu/metagraph
## ls -l /root/models/optimize_me/
ls -l /root/models/linear/cpu/unoptimized
In [14]:
%%bash
freeze_graph
In [13]:
from tensorflow.python.tools import freeze_graph
checkpoint_prefix = os.path.join(self.get_temp_dir(), "saved_checkpoint")
checkpoint_state_name = "checkpoint_state"
input_graph_name = "input_graph.pb"
output_graph_name = "output_graph.pb"
input_graph_path = os.path.join(self.get_temp_dir(),
input_graph_name)
input_saver_def_path = ""
input_binary = False
output_node_names = "output_node"
restore_op_name = "save/restore_all"
filename_tensor_name = "save/Const:0"
output_graph_path = os.path.join(self.get_temp_dir(), output_graph_name)
clear_devices = False
freeze_graph.freeze_graph(input_graph_path,
input_saver_def_path,
input_binary,
checkpoint_path,
output_node_names,
restore_op_name,
filename_tensor_name,
output_graph_path,
clear_devices, "")
Out[13]:
In [11]:
%%bash
## TODO: /root/models/linear/cpu/unoptimized/metagraph.pb
## summarize_graph --in_graph=/root/models/optimize_me/unoptimized_cpu.pb
summarize_graph --in_graph=/root/models/linear/cpu/unoptimized/metagraph.pb
In [ ]:
%%bash
# TODO: shuffle_batch?? x_observed_batch??
transform_graph \
--in_graph=/root/models/optimize_me/unoptimized_cpu.pb \
--out_graph=/root/models/optimize_me/strip_unused_optimized_cpu.pb \
--inputs='x_observed,weights,bias' \
--outputs='add' \
--transforms='
strip_unused_nodes'
In [ ]:
%%bash
ls -l /root/models/optimize_me/
In [ ]:
%%bash
summarize_graph --in_graph=/root/models/optimize_me/strip_unused_optimized_cpu.pb
In [ ]:
%%bash
benchmark_model --graph=/root/models/optimize_me/strip_unused_optimized_cpu.pb --input_layer=weights,bias,x_observed --input_layer_type=float,float,float --input_layer_shape=:: --output_layer=add
In [ ]:
%%bash
transform_graph \
--in_graph=/root/models/optimize_me/unoptimized_cpu.pb \
--out_graph=/root/models/optimize_me/fold_constants_optimized_cpu.pb \
--inputs='x_observed,weights,bias' \
--outputs='add' \
--transforms='
fold_constants(ignore_errors=true)'
In [ ]:
%%bash
ls -l /root/models/optimize_me/
In [ ]:
%%bash
summarize_graph --in_graph=/root/models/optimize_me/fold_constants_optimized_cpu.pb
In [ ]:
%%bash
benchmark_model --graph=/root/models/optimize_me/fold_constants_optimized_cpu.pb --input_layer=x_observed,bias,weights --input_layer_type=float,float,float --input_layer_shape=:: --output_layer=add
In [ ]:
%%bash
transform_graph \
--in_graph=/root/models/optimize_me/fold_constants_optimized_cpu.pb \
--out_graph=/root/models/optimize_me/fold_batch_norms_optimized_cpu.pb \
--inputs='x_observed,weights,bias' \
--outputs='add' \
--transforms='
fold_batch_norms
fold_old_batch_norms'
In [ ]:
%%bash
ls -l /root/models/optimize_me/
In [ ]:
%%bash
summarize_graph --in_graph=/root/models/optimize_me/fold_batch_norms_optimized_cpu.pb
In [ ]:
%%bash
benchmark_model --graph=/root/models/optimize_me/fold_batch_norms_optimized_cpu.pb --input_layer=x_observed,bias,weights --input_layer_type=float,float,float --input_layer_shape=:: --output_layer=add
In [ ]:
%%bash
transform_graph \
--in_graph=/root/models/optimize_me/fold_batch_norms_optimized_cpu.pb \
--out_graph=/root/models/optimize_me/quantized_optimized_cpu.pb \
--inputs='x_observed,weights,bias' \
--outputs='add' \
--transforms='quantize_weights'
In [ ]:
%%bash
ls -l /root/models/optimize_me/
In [ ]:
%%bash
summarize_graph --in_graph=/root/models/optimize_me/quantized_optimized_cpu.pb
In [ ]:
%%bash
benchmark_model --graph=/root/models/optimize_me/quantized_optimized_cpu.pb --input_layer=x_observed,bias,weights --input_layer_type=float,float,float --input_layer_shape=:: --output_layer=add
In [ ]:
%%bash
transform_graph \
--in_graph=/root/models/optimize_me/unoptimized_cpu.pb \
--out_graph=/root/models/optimize_me/fully_optimized_cpu.pb \
--inputs='x_observed,weights,bias' \
--outputs='add' \
--transforms='
add_default_attributes
remove_nodes(op=Identity, op=CheckNumerics)
fold_constants(ignore_errors=true)
fold_batch_norms
fold_old_batch_norms
quantize_weights
quantize_nodes
strip_unused_nodes
obfuscate_names'
In [ ]:
%%bash
ls -l /root/models/optimize_me/
In [ ]:
%%bash
summarize_graph --in_graph=/root/models/optimize_me/fully_optimized_cpu.pb
In [ ]:
%%bash
benchmark_model --graph=/root/models/optimize_me/fully_optimized_cpu.pb --input_layer=weights,x_observed,bias --input_layer_type=float,float,float --input_layer_shape=:: --output_layer=add
In [ ]:
%%bash
transform_graph \
--in_graph=/root/models/optimize_me/fully_optimized_cpu.pb \
--out_graph=/root/models/optimize_me/sort_by_execution_order_optimized_cpu.pb \
--inputs='x_observed,weights,bias' \
--outputs='add' \
--transforms='
sort_by_execution_order'
In [ ]:
%%bash
ls -l /root/models/optimize_me/
In [ ]:
%%bash
summarize_graph --in_graph=/root/models/optimize_me/sort_by_execution_order_optimized_cpu.pb
In [ ]:
%%bash
benchmark_model --graph=/root/models/optimize_me/sort_by_execution_order_optimized_cpu.pb --input_layer=weights,x_observed,bias --input_layer_type=float,float,float --input_layer_shape=:: --output_layer=add
In [ ]: