diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-01-12 03:12:19 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-01-12 03:12:19 +0100 |
| commit | 35a7c163bc6928eae9c54f2a3e686ec308dcf03a (patch) | |
| tree | 4df619bfdf4e7f8b00acf7cffa65444933666255 /cli/app/utils | |
| parent | 74a70b25fc3c5ca401eb70ef015aef4ccf58d4d4 (diff) | |
tf utils to read vectors
Diffstat (limited to 'cli/app/utils')
| -rw-r--r-- | cli/app/utils/tf_utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cli/app/utils/tf_utils.py b/cli/app/utils/tf_utils.py new file mode 100644 index 0000000..69a38e4 --- /dev/null +++ b/cli/app/utils/tf_utils.py @@ -0,0 +1,10 @@ +from tensorflow.python.training import py_checkpoint_reader + +def read_checkpoint(fp_ckpt, key): + reader = py_checkpoint_reader.NewCheckpointReader(fp_ckpt) + var_to_shape_map = reader.get_variable_to_shape_map() + var_to_dtype_map = reader.get_variable_to_dtype_map() + # for key, value in sorted(var_to_shape_map.items()): + # print("tensor: %s (%s) %s" % (key, var_to_dtype_map[key].name, value)) + # print(reader.get_tensor(key)) + return reader.get_tensor(key) |
