This file contains hidden or 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
import numpy as np | |
def load_results(): | |
path = '' #if you run from a different folder | |
a = np.load(path+'test_forward_start_end_ipblob.npy') | |
b = np.load(path+'test_forward_start_end_manual.npy') | |
c = np.load(path+'test_backward_start_end_convblob.npy') | |
d = np.load(path+'test_backward_start_end_manual.npy') | |
return a, b, c, d |
This file contains hidden or 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
#Replace the corresponding functions in test_net.py | |
def test_forward_start_end(self): | |
conv_blob=self.net.blobs['conv']; | |
ip_blob=self.net.blobs['ip_blob']; | |
sample_data=np.random.uniform(size=conv_blob.data.shape); | |
sample_data=sample_data.astype(np.float32); | |
#"""Uncomment the following to load previously stored initializations""" | |
#sample_data=np.load('test_forward_start_end_data.npy'); | |
#self.net.params['ip'][0].data[...]=np.load('test_forward_start_end_weights.npy'); | |
#self.net.params['ip'][1].data[...]=np.load('test_forward_start_end_biases.npy'); |
This file contains hidden or 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
from skimage.transform import rescale | |
import numpy as np | |
import caffe | |
inputArray = np.array( [[0.1, 0.2, 0.3, 0.4], [0.4, 0.3, 0.2, 0.1]] ) | |
scikitResult = rescale(inputArray, scale=2, mode='constant', cval=0) | |
net = caffe.Net('5173_vsScikit.pt', caffe.TRAIN) | |
net.blobs['data'].data[0][0][...] = inputArray | |
net.forward() |
This file contains hidden or 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
input: "data" | |
input_shape { | |
dim: 1 | |
dim: 1 | |
dim: 2 | |
dim: 4 | |
} | |
layer { | |
name: "x2" | |
type: "Deconvolution" |
This file contains hidden or 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
import caffe | |
n = caffe.Net('5173.pt', caffe.TRAIN) | |
for l in n.layers[2:]: | |
print l.blobs[0].data | |
print 'These should be equal:', l.blobs[0].data.flatten()[0], l.blobs[0].data.flatten()[-1] |
This file contains hidden or 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
input: "data" | |
input_shape { | |
dim: 1 | |
dim: 1 | |
dim: 350 | |
dim: 576 | |
} | |
layer { | |
name: "bilinear3" | |
type: "Deconvolution" |
This file contains hidden or 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
input: "data" | |
input_shape { | |
dim: 1 | |
dim: 3 | |
dim: 227 | |
dim: 227 | |
} | |
layer { | |
name: "conv1" | |
type: "Convolution" |