зеркало из https://github.com/microsoft/caffe.git
fix problems in net_surgery.ipynb
This commit is contained in:
Родитель
c6d93dac99
Коммит
4e690b22ae
|
@ -22,7 +22,6 @@
|
|||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"%matplotlib inline\n",
|
||||
"import Image\n",
|
||||
"\n",
|
||||
"# Make sure that caffe is on the python path:\n",
|
||||
"caffe_root = '../' # this file is expected to be in {caffe_root}/examples\n",
|
||||
|
@ -3511,7 +3510,7 @@
|
|||
"print(\"blobs {}\\nparams {}\".format(net.blobs.keys(), net.params.keys()))\n",
|
||||
"\n",
|
||||
"# load image and prepare as a single input batch for Caffe\n",
|
||||
"im = np.array(Image.open('images/cat_gray.jpg'))\n",
|
||||
"im = np.array(caffe.io.load_image('images/cat_gray.jpg', color=False)).squeeze()\n",
|
||||
"plt.title(\"original image\")\n",
|
||||
"plt.imshow(im)\n",
|
||||
"plt.axis('off')\n",
|
||||
|
@ -4480,8 +4479,8 @@
|
|||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"pre-surgery output mean -12.93\n",
|
||||
"post-surgery output mean -11.93\n"
|
||||
"pre-surgery output mean -0.02\n",
|
||||
"post-surgery output mean 0.98\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -4489,7 +4488,7 @@
|
|||
"# pick first filter output\n",
|
||||
"conv0 = net.blobs['conv'].data[0, 0]\n",
|
||||
"print(\"pre-surgery output mean {:.2f}\".format(conv0.mean()))\n",
|
||||
"# set first filter bias to 10\n",
|
||||
"# set first filter bias to 1\n",
|
||||
"net.params['conv'][1].data[0] = 1.\n",
|
||||
"net.forward()\n",
|
||||
"print(\"post-surgery output mean {:.2f}\".format(conv0.mean()))"
|
||||
|
@ -5494,13 +5493,12 @@
|
|||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1,2c1,2\r\n",
|
||||
"1,2c1\r\n",
|
||||
"< # Fully convolutional network version of CaffeNet.\r\n",
|
||||
"< name: \"CaffeNetConv\"\r\n",
|
||||
"---\r\n",
|
||||
"> name: \"CaffeNet\"\r\n",
|
||||
"> input: \"data\"\r\n",
|
||||
"7,11c7\r\n",
|
||||
"7,11c6\r\n",
|
||||
"< input_param {\r\n",
|
||||
"< # initial shape for a fully convolutional network:\r\n",
|
||||
"< # the shape can be set for each input by reshape.\r\n",
|
||||
|
@ -5508,33 +5506,33 @@
|
|||
"< }\r\n",
|
||||
"---\r\n",
|
||||
"> input_param { shape: { dim: 10 dim: 3 dim: 227 dim: 227 } }\r\n",
|
||||
"157,158c153,154\r\n",
|
||||
"157,158c152,153\r\n",
|
||||
"< name: \"fc6-conv\"\r\n",
|
||||
"< type: \"Convolution\"\r\n",
|
||||
"---\r\n",
|
||||
"> name: \"fc6\"\r\n",
|
||||
"> type: \"InnerProduct\"\r\n",
|
||||
"160,161c156,157\r\n",
|
||||
"160,161c155,156\r\n",
|
||||
"< top: \"fc6-conv\"\r\n",
|
||||
"< convolution_param {\r\n",
|
||||
"---\r\n",
|
||||
"> top: \"fc6\"\r\n",
|
||||
"> inner_product_param {\r\n",
|
||||
"163d158\r\n",
|
||||
"163d157\r\n",
|
||||
"< kernel_size: 6\r\n",
|
||||
"169,170c164,165\r\n",
|
||||
"169,170c163,164\r\n",
|
||||
"< bottom: \"fc6-conv\"\r\n",
|
||||
"< top: \"fc6-conv\"\r\n",
|
||||
"---\r\n",
|
||||
"> bottom: \"fc6\"\r\n",
|
||||
"> top: \"fc6\"\r\n",
|
||||
"175,176c170,171\r\n",
|
||||
"175,176c169,170\r\n",
|
||||
"< bottom: \"fc6-conv\"\r\n",
|
||||
"< top: \"fc6-conv\"\r\n",
|
||||
"---\r\n",
|
||||
"> bottom: \"fc6\"\r\n",
|
||||
"> top: \"fc6\"\r\n",
|
||||
"182,186c177,181\r\n",
|
||||
"182,186c176,180\r\n",
|
||||
"< name: \"fc7-conv\"\r\n",
|
||||
"< type: \"Convolution\"\r\n",
|
||||
"< bottom: \"fc6-conv\"\r\n",
|
||||
|
@ -5546,21 +5544,21 @@
|
|||
"> bottom: \"fc6\"\r\n",
|
||||
"> top: \"fc7\"\r\n",
|
||||
"> inner_product_param {\r\n",
|
||||
"188d182\r\n",
|
||||
"188d181\r\n",
|
||||
"< kernel_size: 1\r\n",
|
||||
"194,195c188,189\r\n",
|
||||
"194,195c187,188\r\n",
|
||||
"< bottom: \"fc7-conv\"\r\n",
|
||||
"< top: \"fc7-conv\"\r\n",
|
||||
"---\r\n",
|
||||
"> bottom: \"fc7\"\r\n",
|
||||
"> top: \"fc7\"\r\n",
|
||||
"200,201c194,195\r\n",
|
||||
"200,201c193,194\r\n",
|
||||
"< bottom: \"fc7-conv\"\r\n",
|
||||
"< top: \"fc7-conv\"\r\n",
|
||||
"---\r\n",
|
||||
"> bottom: \"fc7\"\r\n",
|
||||
"> top: \"fc7\"\r\n",
|
||||
"207,211c201,205\r\n",
|
||||
"207,211c200,204\r\n",
|
||||
"< name: \"fc8-conv\"\r\n",
|
||||
"< type: \"Convolution\"\r\n",
|
||||
"< bottom: \"fc7-conv\"\r\n",
|
||||
|
@ -5572,9 +5570,9 @@
|
|||
"> bottom: \"fc7\"\r\n",
|
||||
"> top: \"fc8\"\r\n",
|
||||
"> inner_product_param {\r\n",
|
||||
"213d206\r\n",
|
||||
"213d205\r\n",
|
||||
"< kernel_size: 1\r\n",
|
||||
"219c212\r\n",
|
||||
"219c211\r\n",
|
||||
"< bottom: \"fc8-conv\"\r\n",
|
||||
"---\r\n",
|
||||
"> bottom: \"fc8\"\r\n"
|
||||
|
@ -5610,13 +5608,6 @@
|
|||
}
|
||||
],
|
||||
"source": [
|
||||
"# Make sure that caffe is on the python path:\n",
|
||||
"caffe_root = '../' # this file is expected to be in {caffe_root}/examples\n",
|
||||
"import sys\n",
|
||||
"sys.path.insert(0, caffe_root + 'python')\n",
|
||||
"\n",
|
||||
"import caffe\n",
|
||||
"\n",
|
||||
"# Load the original network and extract the fully connected layers' parameters.\n",
|
||||
"net = caffe.Net('../models/bvlc_reference_caffenet/deploy.prototxt', \n",
|
||||
" '../models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel', \n",
|
||||
|
|
Загрузка…
Ссылка в новой задаче