Download pool/shard010/Python/0089216_export.py from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 924 Bytes
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard010/Python/0089216_export.py
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard010/Python/0089216_export.py
-
curl -L -o 0089216_export.py https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard010/Python/0089216_export.py
924 Bytes
| import os | |
| from keras import backend as K | |
| import tensorflow as tf | |
| from tensorflow.python.tools.freeze_graph import freeze_graph | |
| def exportModelToTF(tfModelOutputDir): | |
| if not os.path.exists(tfModelOutputDir): | |
| os.makedirs(tfModelOutputDir) | |
| # Save checkpoint | |
| saver = tf.train.Saver() | |
| save_path = saver.save(K.get_session(), tfModelOutputDir + "/model") | |
| # Save metagraph | |
| tf.train.write_graph(K.get_session().graph.as_graph_def(), "", tfModelOutputDir + "/metagraph.pb", False) | |
| # Freeze graph | |
| freeze_graph(input_graph=tfModelOutputDir + "/metagraph.pb", input_saver="", input_binary=True, | |
| input_checkpoint=tfModelOutputDir + "/model", output_node_names='softmax/Softmax', | |
| restore_op_name="save/restore_all", filename_tensor_name="save/Const:0", | |
| output_graph=tfModelOutputDir + "/graph.pb", clear_devices=True, initializer_nodes="") | |