{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "%matplotlib inline\n", "import numpy as np\n", "import tensorflow as tf\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(1, 3, 3, 1)\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQ8AAAD8CAYAAABpXiE9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADghJREFUeJzt3X+snmV9x/H3ZxQqUWaLRWlKFckaO+eWiCeIuphmaoKN\noUtkCf4hYDRnOsl00WSoCSYmy9Q/XGYwkgaJsBgkE6PHpcYg4HBZYBxJoRRSaUkWWjtAsEWiU8q+\n++PcmMfj+dXruc/zPAffr+TJc933fZ37+vZq8+n9s01VIUkn6w/GXYCktcnwkNTE8JDUxPCQ1MTw\nkNTE8JDUZKjwSHJmkluTPNx9b1yk33NJ9nafmWHGlDQZMsxzHkk+DzxVVZ9NchWwsar+foF+z1TV\nS4aoU9KEGTY8DgA7qupoks3AD6rqNQv0MzykF5hhw+NYVW3o2gF+9vzyvH4ngL3ACeCzVfWtRfY3\nDUwDvPjFL37D9u3bm2t7oXvuuefGXcLEe/bZZ8ddwsTbv3//T6vqrJafXbdchyTfB85eYNOnBheq\nqpIslkSvqqojSc4Dbk+yr6oOze9UVbuB3QBTU1M1Ozu77C/g99WxY8fGXcLEe+yxx8ZdwsTbvn37\nf7f+7LLhUVVvX2xbkseSbB44bXl8kX0c6b4fSfID4PXA74SHpLVj2Fu1M8DlXfty4NvzOyTZmGR9\n194EvAV4cMhxJY3ZsOHxWeAdSR4G3t4tk2QqyXVdnz8GZpPcB9zB3DUPw0Na45Y9bVlKVT0JvG2B\n9bPAB7r2fwJ/Osw4kiaPT5hKamJ4S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metadata": {}, "output_type": "display_data" } ], "source": [ "sess = tf.InteractiveSession()\n", "image = np.array([[[[1],[2],[3]],\n", " [[4],[5],[6]], \n", " [[7],[8],[9]]]], dtype=np.float32)\n", "print(image.shape)\n", "plt.imshow(image.reshape(3,3), cmap='Greys')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1 filter (2,2,1,1) with padding: VALID\n", "\n", "weight.shape = 1 filter (2 , 2 , 1, 1)\n", "![image](https://cloud.githubusercontent.com/assets/901975/24833375/c0d9c262-1cf9-11e7-9efc-5dd6fe0fedb0.png)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "image.shape (1, 3, 3, 1)\n", "weight.shape (2, 2, 1, 1)\n", "conv2d_img.shape (1, 2, 2, 1)\n", "[[ 12. 16.]\n", " [ 24. 28.]]\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAM0AAAC7CAYAAADGxxq1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACWNJREFUeJzt3V+sZWV5x/HvTxC4oB0HpoEJGpEIWmqbiBOKmggpmCAx\njIk0gRuggUxtS5r0qhgSm3hT9KbRYGsm1BS8QCIXOhqMAXFik2YoEwOOYpCBtIHJKIrNNJO22rFP\nL/ay3TnuM2ce9jp77zN+P8nOWWuv9+z3yZ75zfozb/KkqpB06l637AKkrcbQSE2GRmoyNFKToZGa\nDI3UNFdokpyX5LEkzw8/t68z7hdJnh5e++aZU1q2zPP/NEk+Cfy0qu5Ncjewvar+csa441V17hx1\nSitj3tA8B1xTVUeT7AT2V9XbZowzNDptzHtPc0FVHR22fwhcsM64c5IcTHIgyYfmnFNaqjM3GpDk\nceDCGYfumd6pqkqy3mnrzVV1JMklwBNJDlXVCzPm2gPsGXbftVFt+n/nnuuJvOv48eM/qarf6v7e\nhqGpquvWO5bkR0l2Tl2evbLOZxwZfr6YZD/wTuBXQlNV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I2XUu0GHqyJA8AbkuxcgbraVik0F1TV0WH7h8AF64w7J8nBJAeSbFawLgJemtp/eXhv5piq\nOgEcA87fpHo6dQF8eLgEeiTJmza5plN1qrUvQ2uJ11irnE9JkseBC2ccumd6p6oqyXqP9d5cVUeS\nXAI8keRQVb0wdq1b2FeAh6rqZ0n+mMnZ8A+WXNMq+zaTv1O/XOL1JeBXlnhNW2hoquq69Y4l+VGS\nnVV1dDhtv7LOZxwZfr6YZD/wTibX+WM6Akz/C/3G4b1ZY15Ociawjc1f5bBhXVU1XcP9TO4VV8Gp\nfKcLV1X/PrX9aJK/TbKjTrLEa5Uuz/YBtw3btwFfXjsgyfYkZw/bO4D3As9uQi1PAZcmeUuSs5jc\n6K99Ujdd703AEzXcWW6iDetac59wI/D9Ta7pVO0Dbh2eol0FHJu6HF+a17TEa9FPWU7ylON84BvA\n88DjwHnD+7uA+4ft9wCHmDw1OgTcsYn13AD8gMlZ7J7hvY8DNw7b5wBfBA4D/wxcsqDvaaO6/hr4\n3vAdfRN4+4Lqegg4Cvw3k/uVO4CPAB8Zjgf4zFD3ISYLdlehrrumvq8DwHs2+kxXBEhNq3R5Jm0J\nhkZqMjRSk6GRmgyN1GRopCZDIzUZGqnpfwFown7TRBTL0AAAAABJRU5ErkJggg==\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# print(\"imag:\\n\", image)\n", "print(\"image.shape\", image.shape)\n", "weight = tf.constant([[[[1.]],[[1.]]],\n", " [[[1.]],[[1.]]]])\n", "print(\"weight.shape\", weight.shape)\n", "conv2d = tf.nn.conv2d(image, weight, strides=[1, 1, 1, 1], padding='VALID')\n", "conv2d_img = conv2d.eval()\n", "print(\"conv2d_img.shape\", conv2d_img.shape)\n", "conv2d_img = np.swapaxes(conv2d_img, 0, 3)\n", "for i, one_img in enumerate(conv2d_img):\n", " print(one_img.reshape(2,2))\n", " plt.subplot(1,2,i+1), plt.imshow(one_img.reshape(2,2), cmap='gray')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1 filter (2,2,1,1) with padding:SAME\n", "![image](https://cloud.githubusercontent.com/assets/901975/24833381/fd01869e-1cf9-11e7-9d59-df08c7c6e5c4.png)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "image.shape (1, 3, 3, 1)\n", "weight.shape (2, 2, 1, 1)\n", "conv2d_img.shape (1, 3, 3, 1)\n", "[[ 12. 16. 9.]\n", " [ 24. 28. 15.]\n", " [ 15. 17. 9.]]\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMkAAAC7CAYAAADPLLrPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACVlJREFUeJzt3X+IZXUZx/H3J1enRavdWnGX1VyjRbIfkI6jIsiSCbqI\nK2Sw/pE/UAZE6QcFaYFBkFh/FMmGsajYRKhhMW2ysRhaGqXsKOuPXVmdJHBtwxxzt0VbmXr6457q\nepuZZ93z3e+9M/N5wWXPufe79/kehg/nnnPPfY4iAjOb3bv6PQGzQeeQmCUcErOEQ2KWcEjMEg6J\nWaJVSCS9X9KDkl5o/l0+y7h/StrRPLa0qWlWm9p8TyLpO8BrEXGrpBuB5RHx1RnGHYiI41rM06xv\n2oZkN7AuIvZKWgX8JiJOnWGcQ2LzVttjkhMiYm+z/BfghFnGvVvShKTHJF3asqZZVUuyAZJ+Dayc\n4aWvd69EREiabbd0ckS8LOlDwEOSnomIP85QaxQYbZbPGBoaSjdgPjj22GP7PYVipqam+j2Fkl6N\niOOzQVU+bvX8n7uBByLi/rnGLV26NNasWXPYcxskIyMj/Z5CMWNjY/2eQklPRMRwNqjtx60twJXN\n8pXAL3oHSFouaahZXgGcC+xqWdesmrYhuRW4QNILwKebdSQNS7qjGfMRYELSU8DDwK0R4ZDYvJEe\nk8wlIqaA82d4fgK4tln+PfDxNnXM+snfuJslHBKzhENilnBIzBIOiVnCITFLOC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KG+z2PEhbKtgzadlRpTidpZTMOSSNN3am2tc1qqNWc7jLgOknT\nwJvAxij1Oc/sCKvVnG4TsKltrSNkc78nUNBC2ZaB2o5iB+5mC5UvSzFLLNqQSLpQ0u7mPo439ns+\nh0vSXZJekfRsv+fS1qFc4tQPi/LjlqSjgOeBC+jcdWs7cPkMl9IMPEnnAQfo3G7vY/2eTxvNLQJX\ndV/iBFza77/LYt2TjACTEfFiRLwF3Evnvo7zTkQ8ArzW73mUMKiXOC3WkBzSPRytf5JLnKparCGx\nAVbi/pslLdaQ+B6OA+oQ7r9Z3WINyXZgraRTJB0DbKRzX0fro0O8/2Z1izIkETEN3ABso3Nw+NOI\n2NnfWR0eSfcAfwBOlbRH0jX9nlML/7nE6VNdv2Jd3+9JLcpTwGbvxKLck5i9Ew6JWcIhMUs4JGYJ\nh8Qs4ZCYJRwSs4RDYpb4N4b3ASxEXpwlAAAAAElFTkSuQmCC\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# print(\"imag:\\n\", image)\n", "print(\"image.shape\", image.shape)\n", "\n", "weight = tf.constant([[[[1.]],[[1.]]],\n", " [[[1.]],[[1.]]]])\n", "print(\"weight.shape\", weight.shape)\n", "conv2d = tf.nn.conv2d(image, weight, strides=[1, 1, 1, 1], padding='SAME')\n", "conv2d_img = conv2d.eval()\n", "print(\"conv2d_img.shape\", conv2d_img.shape)\n", "conv2d_img = np.swapaxes(conv2d_img, 0, 3)\n", "for i, one_img in enumerate(conv2d_img):\n", " print(one_img.reshape(3,3))\n", " plt.subplot(1,2,i+1), plt.imshow(one_img.reshape(3,3), cmap='gray')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3 filters (2,2,1,3)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "image.shape (1, 3, 3, 1)\n", "weight.shape (2, 2, 1, 3)\n", "conv2d_img.shape (1, 3, 3, 3)\n", "[[ 12. 16. 9.]\n", " [ 24. 28. 15.]\n", " [ 15. 17. 9.]]\n", "[[ 120. 160. 90.]\n", " [ 240. 280. 150.]\n", " [ 150. 170. 90.]]\n", "[[-12. -16. -9.]\n", " [-24. -28. -15.]\n", " [-15. -17. -9.]]\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAACFCAYAAAB7VhJ6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAB19JREFUeJzt3c+LXGUaxfFzJt3JItqkycxiKMO0Q0TITqn0RpDgKuPG\nrS46GyGrgMJs/COCu2wChtAgikQXLgRxYZABMdYEB/IDh4zJYIvgJCa0ZBFpeGbRxVDDjPRt+977\n3uet7wcKqirN+z7VpzjcvqkfjggBAPL4TekBAAC7Q3EDQDIUNwAkQ3EDQDIUNwAkQ3EDQDIUNwAk\nQ3EDQDIUNwAks9DJogsLsbi42MXSjR08eLDo/pJ079690iMoItzWWuS6rbZcl5eXYzQatbXcr/Lw\n4cOi+0vS4cOHi+5/584d3b17t1GunRT34uKiVlZWuli6sdXV1aL7S9L6+nrpEVpFrttqy3U0GunS\npUtFZ7hy5UrR/SXp1KlTRfcfj8eNf5ZTJQCQDMUNAMlQ3ACQDMUNAMlQ3ACQDMUNAMlQ3ACQDMUN\nAMlQ3ACQDMUNAMlQ3ACQTKPitn3S9te2b9l+o+uh0A9yrRO51m/H4ra9T9I5SX+SdEzSK7aPdT0Y\nukWudSLX+dDkiHtV0q2I+CYifpb0rqSXuh0LPSDXOpHrHGhS3CNJ387c3pjeh9zItU7kOgda+89J\n26dtT2xPtra22loWhZFrnWZzvX//fulxsEtNivs7SUdmbj8xve+/RMT5iBhHxHhhoZPvZ0C7yLVO\nu851eXm5t+HQjibF/aWkp2w/aXu/pJclfdjtWOgBudaJXOfAjodQEbFl+4ykjyXtk3QhIq53Phk6\nRa51Itf50Ohv34j4SNJHHc+CnpFrnci1frxzEgCSobgBIBmKGwCSobgBIBmKGwC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EDQDIUNwAkQ3EDQDIUNwAk44hof1H7X5L+uYclfivpbkvjzPMM\nf4iI37U1DLkOZgZyrXOGxrl2Utx7ZXsSEWNmKD9Dm4bweJihfUN4PPM2A6dKACAZihsAkhlqcZ8v\nPYCYoQtDeDzM0L4hPJ65mmGQ57gBAL9sqEfcAIBfMKjitn3S9te2b9l+o9AMF2z/YPtaof2P2P7U\n9g3b122/VmKOtpXOlly7Me+5TmfoP9uIGMRF0j5J/5D0R0n7Jf1N0rECczwv6VlJ1wr9Hn4v6dnp\n9ccl/b3E76G2bMmVXGvKdkhH3KuSbkXENxHxs6R3Jb3U9xAR8ZmkH/ved2b/7yPi6vT6T5JuShqV\nmqclxbMl107Mfa7TGXrPdkjFPZL07cztDeV/Yu+J7RVJz0j6ouwke0a2M8i1Xn1lO6Tixgzbj0l6\nX9LrEbFZeh60g1zr1We2Qyru7yQdmbn9xPS+uWN7UdtPgLcj4oPS87SAbEWuNes72yEV95eSnrL9\npO39kl6W9GHhmXpn25LeknQzIt4sPU9L5j5bcq1XiWwHU9wRsSXpjKSPtX1y/72IuN73HLbfkfS5\npKdtb9h+tecRnpO0JukF219NLy/2PEOrhpAtubaPXP+j92x55yQAJDOYI24AQDMUNwAkQ3EDQDIU\nNwAkQ3EDQDIUNwAkQ3EDQDIUNwAk828FNQf8XgjbqwAAAABJRU5ErkJggg==\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# print(\"imag:\\n\", image)\n", "print(\"image.shape\", image.shape)\n", "\n", "weight = tf.constant([[[[1.,10.,-1.]],[[1.,10.,-1.]]],\n", " [[[1.,10.,-1.]],[[1.,10.,-1.]]]])\n", "print(\"weight.shape\", weight.shape)\n", "conv2d = tf.nn.conv2d(image, weight, strides=[1, 1, 1, 1], padding='SAME')\n", "conv2d_img = conv2d.eval()\n", "print(\"conv2d_img.shape\", conv2d_img.shape)\n", "conv2d_img = np.swapaxes(conv2d_img, 0, 3)\n", "for i, one_img in enumerate(conv2d_img):\n", " print(one_img.reshape(3,3))\n", " plt.subplot(1,3,i+1), plt.imshow(one_img.reshape(3,3), cmap='gray')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## MAX POOLING\n", "![image](https://cloud.githubusercontent.com/assets/901975/23337676/bd154da2-fc30-11e6-888c-d86bc2206066.png)\n", "\n", "![image](https://cloud.githubusercontent.com/assets/901975/23340355/a4bd3c08-fc6f-11e6-8a99-1e3bbbe86733.png)\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(1, 1, 1, 1)\n", "[[[[ 4.]]]]\n" ] } ], "source": [ "image = np.array([[[[4],[3]],\n", " [[2],[1]]]], dtype=np.float32)\n", "pool = tf.nn.max_pool(image, ksize=[1, 2, 2, 1],\n", " strides=[1, 1, 1, 1], padding='VALID')\n", "print(pool.shape)\n", "print(pool.eval())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## SAME: Zero paddings\n", "\n", "![image](https://cloud.githubusercontent.com/assets/901975/23340337/71b27652-fc6f-11e6-96ef-760998755f77.png)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(1, 2, 2, 1)\n", "[[[[ 4.]\n", " [ 3.]]\n", "\n", " [[ 2.]\n", " [ 1.]]]]\n" ] } ], "source": [ "image = np.array([[[[4],[3]],\n", " [[2],[1]]]], dtype=np.float32)\n", "pool = tf.nn.max_pool(image, ksize=[1, 2, 2, 1],\n", " strides=[1, 1, 1, 1], padding='SAME')\n", "print(pool.shape)\n", "print(pool.eval())" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Extracting MNIST_data/train-images-idx3-ubyte.gz\n", "Extracting MNIST_data/train-labels-idx1-ubyte.gz\n", "Extracting MNIST_data/t10k-images-idx3-ubyte.gz\n", "Extracting MNIST_data/t10k-labels-idx1-ubyte.gz\n" ] } ], "source": [ "from tensorflow.examples.tutorials.mnist import input_data\n", "mnist = input_data.read_data_sets(\"MNIST_data/\", one_hot=True)\n", "# Check out https://www.tensorflow.org/get_started/mnist/beginners for\n", "# more information about the mnist dataset" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP8AAAD8CAYAAAC4nHJkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADY1JREFUeJzt3WuMHXUZx/HfY2kDQcNFcbOhlbXlVuFFhYVIJEaRGiAm\nxYQUN0EqGFdISSgpiQRJ7AteGNNaTEgka2gsRqoSBQox2ktIalMRWlJ3uSlo2rSl9EKh3QaCUh5f\n7KAL7PzP4czMmdl9vp9ks+fMM5cnJ/vbmXNmzvzN3QUgno/V3QCAehB+ICjCDwRF+IGgCD8QFOEH\ngiL8QFCEHwiK8ANBHdfNjZkZlxMCFXN3a2e+Qnt+M7vCzP5uZi+b2R1F1gWgu6zTa/vNbJqkf0ia\nL2m3pKclDbj784ll2PMDFevGnv9iSS+7+7/c/d+Sfi1pQYH1AeiiIuE/XdKucc93Z9Pex8wGzWyr\nmW0tsC0AJav8Az93H5I0JHHYDzRJkT3/Hkmzxj2fmU0DMAkUCf/Tks4ys8+a2QxJ35S0tpy2AFSt\n48N+d3/HzG6R9CdJ0yStcvfnSusMQKU6PtXX0cZ4zw9UrisX+QCYvAg/EBThB4Ii/EBQhB8IivAD\nQRF+ICjCDwRF+IGgCD8QFOEHgiL8QFCEHwiK8ANBEX4gKMIPBEX4gaAIPxAU4QeCIvxAUIQfCIrw\nA0ERfiAowg8ERfiBoAg/EBThB4Ii/EBQhB8IquMhuiXJzHZIGpV0TNI77t5fRlMAqlco/JmvuPvB\nEtYDoIs47AeCKhp+l7TOzLaZ2WAZD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mV5jZ383sZTO7o44e8pjZDjMbMbPtdQ8xlg2Dtt/Mnh037VQzW29mL2W/Jxwm\nrabelpnZnuy1225mV9XU2ywze8LMnjez58zs1mx6ra9doq9aXreuH/ab2TRJ/5A0X9JuSU9LGnD3\n57vaSA4z2yGp391rPydsZl+SdFTSA+5+fjbtx5IOufuPsn+cp7j79xvS2zJJR+seuTkbUKZ3/MjS\nkq6W9G3V+Nol+lqoGl63Ovb8F0t62d3/5e7/lvRrSQtq6KPx3H2TpEMfmLxA0urs8WqN/fF0XU5v\njeDue939mezxqKT3Rpau9bVL9FWLOsJ/uqRd457vVrOG/HZJ68xsm5kN1t3MBHqyYdMl6VVJPXU2\nM4GWIzd30wdGlm7Ma9fJiNdl4wO/D7vU3S+QdKWkxdnhbSP52Hu2Jp2uaWvk5m6ZYGTp/6nztet0\nxOuy1RH+PZJmjXs+M5vWCO6+J/u9X9LDat7ow/veGyQ1+72/5n7+p0kjN080srQa8No1acTrOsL/\ntKSzzOyzZjZD0jclra2hjw8xsxOzD2JkZidK+pqaN/rwWkmLsseLJD1aYy/v05SRm/NGllbNr13j\nRrx2967/SLpKY5/4/1PSD+roIaev2ZL+lv08V3dvktZo7DDwPxr7bOQ7kj4paaOklyRtkHRqg3r7\npaQRScMaC1pvTb1dqrFD+mFJ27Ofq+p+7RJ91fK6cYUfEBQf+AFBEX4gKMIPBEX4gaAIPxAU4QeC\nIvxAUIQfCOq/esVX4lsZQ0YAAAAASUVORK5CYII=\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "img = mnist.train.images[0].reshape(28,28)\n", "plt.imshow(img, cmap='gray')" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Tensor(\"Conv2D_3:0\", shape=(1, 14, 14, 5), dtype=float32)\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAABcCAYAAAB+6068AAAABHNCSVQICAgIf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CCLEEBnRCCLEEBnRCCLEEBnRCCLEEBnRCCLEEBnRCCLEEBnRCCLEE\nBnRCCLGE/wPkBmjsLVFsSgAAAABJRU5ErkJggg==\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "sess = tf.InteractiveSession()\n", "\n", "img = img.reshape(-1,28,28,1)\n", "W1 = tf.Variable(tf.random_normal([3, 3, 1, 5], stddev=0.01))\n", "conv2d = tf.nn.conv2d(img, W1, strides=[1, 2, 2, 1], padding='SAME')\n", "print(conv2d)\n", "sess.run(tf.global_variables_initializer())\n", "conv2d_img = conv2d.eval()\n", "conv2d_img = np.swapaxes(conv2d_img, 0, 3)\n", "for i, one_img in enumerate(conv2d_img):\n", " plt.subplot(1,5,i+1), plt.imshow(one_img.reshape(14,14), cmap='gray')" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Tensor(\"MaxPool_2:0\", shape=(1, 7, 7, 5), dtype=float32)\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAABcCAYAAABOZ1+dAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACadJREFUeJzt3U1oVGkWBuD3pJIY7UQSE43QyYw10DIExDhoVtmMgvQs\ntBeC9Pi3EbJqdSXMKmAWMjsddRB0aMRF066UFho7rZteiNDGH9p24pAxtp1AbBPjJP7EWObMwoop\nc6u+71buX33W+0CjqXO93+HtqkPl1r23RFVBRETuqEi6ASIiKg4HNxGRYzi4iYgcw8FNROQYDm4i\nIsdwcBMROYaDm4jIMRzcRESO4eAmInJMZRQ7FZGyuBxTVcXvthUVFZpKpaJspyRkMplRVV3uZ9vG\nxkZtbW2NuqXE3b5923cm5fLaAeA7EwCoq6vTpqamKPtJ3OjoKCYnJ33NFF+DW0Q+BfAPACkA/1LV\nvwfo74MhIvfgM5NUKoX6+vp4GkvI9PQ0JiYm6kRkAD4yaW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HT09PGehgX2JisWrUKCDGTONheWyEp\nuUxsXxAR9AKbMPF0QCIix3BwExE5hoObiMgxHNxERI7h4CYicgwHNxGRYzi4iYgcE9UXKTwG8EvO\nQ00ASv32jcX2+HtVXe534zLJBCgiF2bilSeTha4ZN75+vCLLJJLB7VlE5HqpnWw/X9w9MpPk11uI\nJHpkLsmvtxBR9shDJUREjuHgJiJyTFyD+1RM6wQRd4/MJPn1FiKJHplL8ustRGQ9xnKMm4iIwsND\nJUREjol0cIvIpyJyT0QGRORvUa4VhIg8EJGfRORW1N/7x0wKrlfyuTATL2aSX+S5qGok/wFIAfgv\ngD8AqAZwG0BbVOsF7PUBgKYY1mEmDufCTJhJqeQS5TvuDgADqnpfVacBfA3gswjXcwEzyY+5eDET\nL2aSFeXg/hjArzk/D2UfK0UKoFdE+kSkK8J1mEl+ruTCTLyYSX6R5uLnOyfLQaeqDovICgDfi0i/\nqv6QdFMJYyZezMSLmeQXaS5RvuMeBtCa83NL9rGSo6rD2T9/A3Aeb38liwIzyc+JXJiJFzPJL+pc\nohzcPwL4RETSIlIN4HMA30S43oKIyEciUjf7dwCbAdyJaDlmkl/J58JMvJhJfnHkEtmhElXNiMgX\nAL7D20+Dv1TVn6NaL4BmAOdFBHibx1eqGvwr4PNgJvk5kgsz8WIm+UWeC6+cJCJyDK+cJCJyDAc3\nEZFjOLiJiBzDwU1E5BgObiIix3BwExE5hoObiMgxHNxERI75P73Ea1xD26TyAAAAAElFTkSuQmCC\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "pool = tf.nn.max_pool(conv2d, ksize=[1, 2, 2, 1], strides=[\n", " 1, 2, 2, 1], padding='SAME')\n", "print(pool)\n", "sess.run(tf.global_variables_initializer())\n", "pool_img = pool.eval()\n", "pool_img = np.swapaxes(pool_img, 0, 3)\n", "for i, one_img in enumerate(pool_img):\n", " plt.subplot(1,5,i+1), plt.imshow(one_img.reshape(7, 7), cmap='gray')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.0" } }, "nbformat": 4, "nbformat_minor": 0 }