MCPcopy Create free account
hub / github.com/BVLC/caffe / array_to_blobproto

Function array_to_blobproto

python/caffe/io.py:36–46  ·  view source on GitHub ↗

Converts a N-dimensional array to blob proto. If diff is given, also convert the diff. You need to make sure that arr and diff have the same shape, and this function does not do sanity check.

(arr, diff=None)

Source from the content-addressed store, hash-verified

34 return data.reshape(blob.shape.dim)
35
36def array_to_blobproto(arr, diff=None):
37 """Converts a N-dimensional array to blob proto. If diff is given, also
38 convert the diff. You need to make sure that arr and diff have the same
39 shape, and this function does not do sanity check.
40 """
41 blob = caffe_pb2.BlobProto()
42 blob.shape.dim.extend(arr.shape)
43 blob.data.extend(arr.astype(float).flat)
44 if diff is not None:
45 blob.diff.extend(diff.astype(float).flat)
46 return blob
47
48
49def arraylist_to_blobprotovector_str(arraylist):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected