forked from BVLC/caffe
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from lukeyeager/nvidia/cherry-picks
Cherry pick some commits for v0.14
- Loading branch information
Showing
12 changed files
with
172 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import numpy as np | ||
import unittest | ||
|
||
import caffe | ||
|
||
class TestBlobProtoToArray(unittest.TestCase): | ||
|
||
def test_old_format(self): | ||
data = np.zeros((10,10)) | ||
blob = caffe.proto.caffe_pb2.BlobProto() | ||
blob.data.extend(list(data.flatten())) | ||
shape = (1,1,10,10) | ||
blob.num, blob.channels, blob.height, blob.width = shape | ||
|
||
arr = caffe.io.blobproto_to_array(blob) | ||
self.assertEqual(arr.shape, shape) | ||
|
||
def test_new_format(self): | ||
data = np.zeros((10,10)) | ||
blob = caffe.proto.caffe_pb2.BlobProto() | ||
blob.data.extend(list(data.flatten())) | ||
blob.shape.dim.extend(list(data.shape)) | ||
|
||
arr = caffe.io.blobproto_to_array(blob) | ||
self.assertEqual(arr.shape, data.shape) | ||
|
||
def test_no_shape(self): | ||
data = np.zeros((10,10)) | ||
blob = caffe.proto.caffe_pb2.BlobProto() | ||
blob.data.extend(list(data.flatten())) | ||
|
||
with self.assertRaises(ValueError): | ||
caffe.io.blobproto_to_array(blob) | ||
|
||
def test_scalar(self): | ||
data = np.ones((1)) * 123 | ||
blob = caffe.proto.caffe_pb2.BlobProto() | ||
blob.data.extend(list(data.flatten())) | ||
|
||
arr = caffe.io.blobproto_to_array(blob) | ||
self.assertEqual(arr, 123) |
Oops, something went wrong.