def test_googlenet_model_inference(self): if self.__class__.resolver.has_pycaffe(): caffe = self.__class__.resolver.caffe data_file = self.__class__.data_file def_file = self.__class__.def_file images = np.load(self.__class__.npz_file) images = [crop_center(images[im], 224, 224) for im in images] # transformation is based on https://tinyurl.com/y7emcayd mean = np.array([104, 117, 123]).reshape((1, 3, 1, 1)) data = np.array(images, dtype=np.float32) - mean net = caffe.Net(def_file, data_file, caffe.TEST) caffe_probs = net.forward_all(data=data)['prob'] model = pydaal.transform_proto(def_file) net = pydaal.DAALNet().build(model, trainable=False, caffe_model_path=data_file) with net.predict(data, batch_size=2) as daal_probs: assert_allclose(daal_probs, caffe_probs, rtol=1e-02) assert_array_equal(np.argmax(daal_probs, 1), np.argmax(caffe_probs, 1))
def test_alexnet_model_buildup_from_proto(self): daal_model = pydaal.transform_proto(self.__class__.def_file) assert len(daal_model.outputs) == 1 assert type(daal_model.outputs[0]) == Softmax assert 'conv1' in daal_model.nodes assert 'conv2' in daal_model.nodes assert 'conv3' in daal_model.nodes assert 'conv4' in daal_model.nodes assert 'conv5' in daal_model.nodes assert daal_model.nodes['conv1'].depth == 0 assert daal_model.nodes['conv2'].depth == 4 assert daal_model.nodes['conv3'].depth == 8 assert daal_model.nodes['conv4'].depth == 10 assert daal_model.nodes['conv5'].depth == 12
def test_resnet_model_buildup_from_proto(self): daal_model = pydaal.transform_proto(self.__class__.def_file) assert len(daal_model.outputs) == 1 assert type(daal_model.outputs[0]) == Softmax assert 'conv1' in daal_model.nodes assert 'pool1' in daal_model.nodes assert 'bn_conv1' in daal_model.nodes assert 'scale_conv1' in daal_model.nodes assert 'prob' in daal_model.nodes assert daal_model.nodes['conv1'].depth == 0 assert daal_model.nodes['bn_conv1'].depth == 1 assert daal_model.nodes['scale_conv1'].depth == 2 assert daal_model.nodes['pool1'].depth == 4 assert daal_model.nodes['prob'].depth == 215
def test_googlenet_model_buildup_from_proto(self): daal_model = pydaal.transform_proto(self.__class__.def_file) assert len(daal_model.outputs) == 1 assert type(daal_model.outputs[0]) == Softmax assert 'conv1/7x7_s2' in daal_model.nodes assert 'conv2/3x3_reduce' in daal_model.nodes assert 'conv2/3x3' in daal_model.nodes assert 'inception_3a/1x1' in daal_model.nodes assert 'inception_3b/1x1' in daal_model.nodes assert 'inception_3a/3x3_reduce' in daal_model.nodes assert daal_model.nodes['conv1/7x7_s2'].depth == 0 assert daal_model.nodes['conv2/3x3_reduce'].depth == 4 assert daal_model.nodes['conv2/3x3'].depth == 6 assert daal_model.nodes['inception_3a/1x1'].depth == 10 assert daal_model.nodes['inception_3a/3x3_reduce'].depth == 10 assert daal_model.nodes['inception_3b/1x1'].depth == 15