tensorflow - Freeze tensor_forest graph for Android -




i built aimple random forest model in tensorflow, , want freeze & optimize android. used following function building tesnor_forest estimator:

def build_estimator(_model_dir, _num_classes, _num_features, _num_trees, _max_nodes):       params = tensor_forest.foresthparams(       num_classes=_num_classes, num_features=_num_features,       num_trees=_num_trees, max_nodes=_max_nodes, min_split_samples=3)      graph_builder_class = tensor_forest.randomforestgraphs     return random_forest.tensorforestestimator(       params, graph_builder_class=graph_builder_class,       model_dir=_model_dir) 

this function stores textual model graph.pbtxt file in specified model directory.

then train using:

est = build_estimator(output_model_dir, 3,np.size(features_eval,1), 5,6) train_x = features_eval.astype(dtype=np.float32) train_y = labels_y.astype(dtype=np.float32) est.fit(x=train_x, y=train_y, batch_size=np.size(features_eval,0)) 

(in simple example: number of trees = 5, max_nodes=6)

now want freeze model, call function:

def save_model_android(model_path): checkpoint_state_name = "model.ckpt-1" input_graph_name = "graph.pbtxt" output_graph_name = "freezed_model.pb" checkpoint_path = os.path.join(model_path, checkpoint_state_name)  input_graph_path = os.path.join(model_path, input_graph_name) input_saver_def_path = none input_binary = false output_node_names = "output" restore_op_name = "save/restore_all" filename_tensor_name = "save/const:0" output_graph_path = os.path.join(model_path, output_graph_name) clear_devices = true  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, "") 

and in freezed_model.pb file generated 1 op output node. in console following message when freeze_graph function called:

converted 0 variables const ops. 1 ops in final graph. 

does knows why 1 node exported when calling freeze_graph?

i'm using tensorflow version 1.2.1 cuda support , installed sources on linux





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -