aboutsummaryrefslogtreecommitdiff
path: root/scripts/caffe_data_extractor.py
diff options
context:
space:
mode:
authorPablo Marquez Tello <pablo.tello@arm.com>2022-07-20 09:16:20 +0100
committerPablo Marquez Tello <pablo.tello@arm.com>2022-07-20 10:36:30 +0000
commit3964f17fd46a8b1ee39ea10408d3825c9a67af0b (patch)
tree0cbcdbaa998a6dad8b6c023998b77ee460f58ce6 /scripts/caffe_data_extractor.py
parent553f6953fe3bdfad53c11c25f305a16d79d83b24 (diff)
downloadComputeLibrary-3964f17fd46a8b1ee39ea10408d3825c9a67af0b.tar.gz
Remove data extraction scripts
* Resolved MLCE-886 Change-Id: I3b8fbe662c715b82c08c63fa27892471a572fdd8 Signed-off-by: Pablo Marquez Tello <pablo.tello@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7945 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Gunes Bayir <gunes.bayir@arm.com> Benchmark: Gunes Bayir <gunes.bayir@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'scripts/caffe_data_extractor.py')
-rwxr-xr-xscripts/caffe_data_extractor.py45
1 files changed, 0 insertions, 45 deletions
diff --git a/scripts/caffe_data_extractor.py b/scripts/caffe_data_extractor.py
deleted file mode 100755
index 47d24b265f..0000000000
--- a/scripts/caffe_data_extractor.py
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env python
-"""Extracts trainable parameters from Caffe models and stores them in numpy arrays.
-Usage
- python caffe_data_extractor -m path_to_caffe_model_file -n path_to_caffe_netlist
-
-Saves each variable to a {variable_name}.npy binary file.
-
-Tested with Caffe 1.0 on Python 2.7
-"""
-import argparse
-import caffe
-import os
-import numpy as np
-
-
-if __name__ == "__main__":
- # Parse arguments
- parser = argparse.ArgumentParser('Extract Caffe net parameters')
- parser.add_argument('-m', dest='modelFile', type=str, required=True, help='Path to Caffe model file')
- parser.add_argument('-n', dest='netFile', type=str, required=True, help='Path to Caffe netlist')
- args = parser.parse_args()
-
- # Create Caffe Net
- net = caffe.Net(args.netFile, 1, weights=args.modelFile)
-
- # Read and dump blobs
- for name, blobs in net.params.iteritems():
- print('Name: {0}, Blobs: {1}'.format(name, len(blobs)))
- for i in range(len(blobs)):
- # Weights
- if i == 0:
- outname = name + "_w"
- # Bias
- elif i == 1:
- outname = name + "_b"
- else:
- continue
-
- varname = outname
- if os.path.sep in varname:
- varname = varname.replace(os.path.sep, '_')
- print("Renaming variable {0} to {1}".format(outname, varname))
- print("Saving variable {0} with shape {1} ...".format(varname, blobs[i].data.shape))
- # Dump as binary
- np.save(varname, blobs[i].data)