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)
| 34 | return data.reshape(blob.shape.dim) |
| 35 | |
| 36 | def 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 | |
| 49 | def arraylist_to_blobprotovector_str(arraylist): |
no outgoing calls
no test coverage detected