Compute Library
 21.02
tf_frozen_model_extractor Namespace Reference

Variables

list strings_to_remove = ["read", "/:0"]
 
dictionary permutations = { 1 : [0], 2 : [1, 0], 3 : [2, 1, 0], 4 : [3, 2, 0, 1]}
 
 parser = argparse.ArgumentParser('Extract TensorFlow net parameters')
 
 dest
 
 type
 
 str
 
 required
 
 True
 
 help
 
 False
 
 default
 
 action
 
 storeRes
 
 args = parser.parse_args()
 
 graph_def = tf.GraphDef()
 
 input_map
 
 None
 
 return_elements
 
 name
 
 op_dict
 
 producer_op_list
 
 varname = op_val.name
 
 t = op_val.eval()
 
 tT = t.transpose(permutations[len(t.shape)])
 

Detailed Description

Extract trainable parameters from a frozen model and stores them in numpy arrays.
Usage:
    python tf_frozen_model_extractor -m path_to_frozem_model -d path_to_store_the_parameters

Saves each variable to a {variable_name}.npy binary file.

Note that the script permutes the trainable parameters to NCHW format. This is a pretty manual step thus it's not thoroughly tested.

Variable Documentation

◆ action

action

Definition at line 24 of file tf_frozen_model_extractor.py.

◆ args

args = parser.parse_args()

Definition at line 26 of file tf_frozen_model_extractor.py.

◆ default

default

Definition at line 23 of file tf_frozen_model_extractor.py.

◆ dest

dest

Definition at line 22 of file tf_frozen_model_extractor.py.

◆ False

False

Definition at line 23 of file tf_frozen_model_extractor.py.

◆ graph_def

graph_def = tf.GraphDef()

Definition at line 37 of file tf_frozen_model_extractor.py.

◆ help

help

Definition at line 22 of file tf_frozen_model_extractor.py.

◆ input_map

input_map

Definition at line 41 of file tf_frozen_model_extractor.py.

◆ name

name

Definition at line 41 of file tf_frozen_model_extractor.py.

◆ None

◆ op_dict

op_dict

Definition at line 41 of file tf_frozen_model_extractor.py.

◆ parser

parser = argparse.ArgumentParser('Extract TensorFlow net parameters')

Definition at line 21 of file tf_frozen_model_extractor.py.

◆ permutations

dictionary permutations = { 1 : [0], 2 : [1, 0], 3 : [2, 1, 0], 4 : [3, 2, 0, 1]}

Definition at line 17 of file tf_frozen_model_extractor.py.

◆ producer_op_list

producer_op_list

Definition at line 41 of file tf_frozen_model_extractor.py.

◆ required

required

Definition at line 22 of file tf_frozen_model_extractor.py.

◆ return_elements

return_elements

Definition at line 41 of file tf_frozen_model_extractor.py.

◆ storeRes

storeRes

Definition at line 25 of file tf_frozen_model_extractor.py.

◆ str

str

Definition at line 22 of file tf_frozen_model_extractor.py.

◆ strings_to_remove

list strings_to_remove = ["read", "/:0"]

Definition at line 16 of file tf_frozen_model_extractor.py.

◆ t

◆ True

True

Definition at line 22 of file tf_frozen_model_extractor.py.

◆ tT

tT = t.transpose(permutations[len(t.shape)])

Definition at line 50 of file tf_frozen_model_extractor.py.

◆ type

type

Definition at line 22 of file tf_frozen_model_extractor.py.

◆ varname

varname = op_val.name

Definition at line 45 of file tf_frozen_model_extractor.py.