Convolutions
 Share
The version of the browser you are using is no longer supported. Please upgrade to a supported browser.Dismiss

 
View only
 
 
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBW
1
2
Convolutions & Image FiltersInput
3
4
We've been using convolutional neural networks this whole time but I don't think I've written a single word about what a convolution IS.

I find it helpful to think of a convolution as the act of using a bunch of filters to produce different "versions" of an image so your neural network can more easily identify patterns in it.

The features highlighted by a filter can range from the simple (edges or curves) to the complex (eyes and noses).
0000000000000000000000000000
5
0000000000000000000000000000
6
0000000000000000000000000000
7
0000000000000000000000000000
8
0000000000000000000000000000
9
0000000000003181818126136175261662552471270000
10
00000000303694154170253253253253253225172253242195640000
11
000000049238253253253253253253253253251938282563900000
12
0000000182192532532532532531981822472410000000000
13
Here are some examples of filters from Victor Powell's visual explanation of image kernels:0000000080156107253253205110431540000000000
14
0000000001411542539000000000000000
15
0000000000013925319020000000000000
16
SharpenEmbossBlur0000000000011190253700000000000000
17
0-10-2-100.10.10.10000000000003524122516010810000000000
18
-15-1-1110.10.30.100000000000008124025325311925000000000
19
0-100120.10.10.100000000000000451862532531502700000000
20
000000000000000169325225318700000000
21
These names might be familiar if you use Photoshop, or Instagram, or VSCO.

I find the filters for sharpen and blur to be really interesting, because you can kind of guess the effect they would have on an image just by looking at their pixel values:

Sharpen emphasizes pixels (multiplying each by 5) and creates contrast (multiplying adjacent pixels by -1). Blur has the opposite effect - it reduces pixel intensity by lowering their absolute values.

On the right I've copied the pixel values from one entry in the MNIST data set. Let's see what it looks like when we apply the sharpen and blur filters.
00000000000000000249253249640000000
22
000000000000004613018325325320720000000
23
0000000000003914822925325325325018200000000
24
00000000002411422125325325325320178000000000
25
0000000023662132532532532531988120000000000
26
00000018171219253253253253195809000000000000
27
0000551722262532532532532441331100000000000000
28
0000136253253253212135132160000000000000000
29
0000000000000000000000000000
30
0000000000000000000000000000
31
0000000000000000000000000000
32
33
Applied FiltersSharpen & Blur
34
35
Our blurred image really does look blurred, which is really cool.

What's going on with our sharpen filter though? I have to say I wasn't expecting it to look like that, but if we look a little closer it does make sense. The negative values immediately around the edges of the digit created a new floor for pixel values, shifting the 0s to the center of the distribution.

You might have noticed that filtering created a 26x26 image from the original 28x28. Filters can't act on empty space, so to avoid losing information we usually add a border of 1s to the image each time we perform a convolution (this is the role of the ZeroPadding layer in Keras).
Sharpen
Blur
36
0-100.10.10.6
37
-15-10.10.30.1
38
0-100.10.10.1
39
40
41
0000000000000000000000000000000000000000000000000000
42
0000000000000000000000000000000000000000000000000000
43
0000000000000000000000000000000000000000000000000000
44
0000000000-3-21-39-54-162-280-437-337-367-447-668-629-374-1270000000000002.437517.062531.687543.875131.625227.5355.0625273.8125298.1875363.1875542.75511.0625303.875103.187500
45
000000-30-66-160-284-409-514-559-597-27381580361451674131413868633170000000024.37553.625130230.75341.125479.3125568.75643.6875697.6875756.6875812.4375696.625711.625765.4375894.625721.5625397.4375115.500
46
00000-49-197-342-2649349295112301464135612401159118713261334122577936465000000039.8125248.1875471.75684.5758.6875826.4375910.4375964.43751009.68751036.68751064.5625959.8125755.375625.5625624655.8125484.9375254.687563.7500
47
If you're interested in seeing the effects of different filters, the post I linked to earlier has a bunch.000001295941064134712341100941897885891842572387121-7-159-216-142-64000000039.125343.5625684.6251001.06251067.18751100.68751140.43751120.51083.56251078.68751112.625877.75571.3125291276.75261172.7584.251600
48
0000053446941088100290580788492410681056670143-257-220-177-95-390000000021.25255.25571.75827.1875988.51067.31251146.9375922.8125681.75547.125684.3125553.3125352.12564.255544.2523.759.75000
49
00000-183204289620672877360-75-465-7910322100000000000004.599.25251.875364.9375585.0625827.75949.0625689.1875339.375183.75266220.5137.2500000000
50
The difference between these filters and the ones we're going to use in the convolutional layers of our network, however, is that our network filters are going to be generated at random (just like the weights in our dense layers).000000-80-194-298-148219198115-138-56-197-197-15400000000000000206693.25326.4375675.75899.125650.312525515.12549.2549.2538.500000000
51
0000000-14-15237567795479163-640000000000000000003.53.75120.6875461.3125784.125725.0625380.937557.87500000000000
52
000000000-106176504593151-285-269-109-10000000000000000040.25226.9375596.75774.8125718.125436.0625218.562588.56250.812500000000
53
000000000-11-96293669981663182-70-141-2500000000000000002.7567.75317.3125639.5625860.125870.125642.3125377.0625117.520.31250000000
54
0000000000-35-3341786512619144261-102-2700000000000000008.75109.5322.3125631.1875889.5942758.75421.625156.312521.9375000000
55
00000000000-81-186103597109097345466-1060000000000000000020.25102.75272517.0625795.5625913.125813.25452.25165.4375000000
56
000000000000-45-183-157142636895577221-640000000000000000011.2565.75175.5555.8125870.8751063.6875724.125354.56255200000
57
000000000000-46-192-468-1802198487965431900000000000000000037.375147318.9375674.625960.31251127.8125768.375373.062533.62500000
58
0000000000-39-187-278-102342690809703388132-5800000000000000031.6875151.9375361599.875776.6875961.93751084.251100.8125723.5330.6251700000
59
00000000-24-138-242-274759551087100410471063756337-2000000000000019.5112.125311.1875571.25810.1875975.68751073.93751095.4375982.5747.4375394.875143.250.500000
60
000000-23-89-230-118319818100694310101081757150-198-18200000000000018.687572.3125257.375501.25773.4375957.43751084.18751109995.5771.5625522.4375312.37514745.5000000
61
0000-18-189-339-376157699103998810221069748127-283-273-780000000000014.625153.5625343566.9375746.0625917.18751065.93751096.0625990.25772.5528.0625324.5625174.570.7519.50000000
62
00-55-227-399-8446910811114995928956681137-265-254-83-2000000000044.6875184.4375377.0625623.4375804.5960.43751054.68751121.8751071.125855.5570.75326.9375177.574.7520.750.500000000
63
002929269910051070103410731208983447-96-251-89-9000000000000138429.5625752.625989.43751051.3751027.75949.9375794.6875625382.2520476.522.252.250000000000
64
00353940147316261422104167899-186-340-144-110000000000000081.75251.25434.25542.25542489.75429.25329231.5105362.75000000000000
65
00-136-389-642-759-718-600-479-283-148-1600000000000000003497.25160.5189.75179.5150119.7570.7537400000000000000
66
0000000000000000000000000000000000000000000000000000
67
68
69
Randomly Generated FiltersFirst Convolutional Layer + ZeroPadding
70
71
Here we have two 3x3 filters with randomly generated values. This is the equivalent of calling Conv2D(2, input_shape=(28, 28)) in Keras.

Without explicitly trying to, we seem to have created some kind of... Top edge filter. And a filter that produces a result kind of similar to the one produced by our blur filter, even though the filter values are totally different!

We didn't zero pad our input, but let's do it for our filtered images, so we don't continue to lose information with the next convolution. That's the black border of 0s around our filtered image.
Filter 1
Filter 2
72
5-3-2843
73
-63-29-46
74
-8-512053
75
76
00000000000000000000000000000000000000000000000000000000
77
00000000000000000000000000000000000000000000000000000000
78
00000000000000000000000000000000000000000000000000000000
79
00000000000000000000000000000000000000000000000000000000
80
0000000000024.54171.78319.02441.721325.162290.43574.662756.663002.063656.465464.245145.223059.321038.860000000000000037.2260.4483.6669.62008.834725418.84178.84550.85542.88283.27799.64637.61574.8000
81
0000000245.4539.881308.82323.123405.954626.835356.915969.45490.964968.224043.673824.093691.193475.852684.961311.71461.8-39.090000000000372818.419843521.65196.77249.38557.99654.610140.610671.611030.99576.59711.510282.3115629042.94894.61365.1000
82
000000400.822214.764124.825377.124950.54329.973464.142864.112361.871393.11318.29-2274.76-2417.71-4069.23-5164.8-7600.8-7084.46-4183.13-1422.71000000000607.63693.869939945.610689.611343.8112366.5713119.3313748.8815592.4417581.918151.8913959.9912376.4913359.7916702.5614169.538033.282455.89000
83
000000-69.83398.151023.981199.38298.77-903.21-2329.44-3667.37-4992.66-5041.74-4681.14-5209.94-5746.3-6969.01-6957.59-6973.41-4914.82-2496-574.08000000000443.74742.49632.6215069.217674.9819962.3622676.4923684.4224220.8324146.4324670.6321215.8716000.91225212375.6912574.88979.574596.631092.48000
84
000000-519.27-2969.9-5084.02-7079.69-5949.72-5156.26-4354.62-6090.53-7845.54-9144.12-8146.93-5905.47-3629.13-2305.29-1973.4-1587.69-852.15-349.830000000000917.436957.5914349.220215.7822770.0323972.8325188.0321939.7318483.0316447.2318379.7914829.5910265.924386.993755.43021.391621.65665.730000
85
000000-161.46-2480.29-5326.26-7900.04-7711.69-6186.38-5892.5-5586.81-5898.69-5863.41-6882.61-5250.07-2843.99000000000000000307.264405.599599.914105.2517373.7320773.8322318.4318380.9812893.3110945.8912323.49216.664806.87000000000
86
0000000-717.6-2178.94-3143.16-4240.17-4099.49-3818.62-2086.32-765.66-468.02-1767.09-1767.09-1381.3800000000000000001365.64091.525922.5111292.2217160.7121590.0715067.336472.92946.583362.793362.792628.78000000000
87
00000000-125.58-134.55-2041.72-3752.14-3322.63-851.72984.28563.7400000000000000000000238.98256.053646.7311220.9616732.3914218.716405.5877000000000000
88
0000000000-1295.56-4120.37-4974.08-2166.061967.553704.72200.42891.628.1800000000000000000002422.238029.9415400.1416117.0512493.346462.343335.61351.612.4000000000
89
0000000000-98.67-1958.02-4632.48-4195.26-975.173290.393920.832764.591173.49204.5000000000000000000187.773588.579996.1814991.8115448.2112663.88960.55413.31790.131000000000
90
00000000000-313.95-2834.55-5547.9-6268.46-3767.87478.882629.642870.511337.11220.86000000000000000000597.455075.8210554.5716133.2217774.1115985.1311781.535997.072307.3334.80000000
91
000000000000-726.57-3078.72-6041.23-7944.12-5718.83-1575.532463.982590.841410.0500000000000000000001382.675681.9711036.0816263.8218259.1517143.9912973.886679.252440.30000000
92
0000000000000-403.65-2142.95-4824.35-5769.65-4427.1-779.481092.991489.74523.520000000000000000000768.154015.178752.3816524.5420113.7219766.512019.795183.59793.6000000
93
0000000000000376.281296.161958.89288.64-1951.9-3701.83-2675.02-1354.36-267.160000000000000000000570.42455.526312.2314301.1721010.4624033.1415786.67192.19312.8000000
94
00000000000319.021529.663199.14373.724421.931467.71-1371.13-4291.76-3589.92-2244.72-582.9400000000000000000483.62318.85365.4860410729.516209.0321044.0424522.0717097.428540.211101.48000000
95
000000000196.321128.842763.853981.433691.361839-267.66-2656.13-5177.65-7147.94-5419.86-2680.99-17.94000000000000000297.61711.24627.18132.711672.0215250.9218847.2321843.9221760.0318713.0110797.544386.6334.14000000
96
0000000188.14728.022364.043740.423941.221926.39-743.51-3254.75-5603.56-7641.66-8459.14-7364.06-4220.58-1632.5400000000000000285.21103.63852.87217.811196.8315249.6919784.2222899.222558.7519622.0316328.1212973.257725.243106.740000000
97
00000147.241546.023235.554865.474377.362614-196.78-2902.55-5564.52-7603.83-8436.97-7513-5139.73-2511.49-699.660000000000000223.22343.65162.78373.710758.6814161.2618775.2322145.0622372.5919645.7316453.7313444.599454.744771.531331.4600000000
98
000449.91856.863625.84487.913974.012561.8287.93-1999.41-4658.4-6739.82-7969.35-7483.02-5166.31-2560.44-744.51-17.940000000000006822814.85698.28922.911305.4113824.3317829.2421796.7423500.8320921.8317117.7313431.689481.744837.171416.8134.14000000000
99
000868.832176.413083.311629.36-1029.28-4222.08-5947.4-7815.79-8388.49-7875.93-5374.08-2596.21-798.33-80.73000000000000001933.95845.110306.5615567.3319161.7621831.5121730.8519840.3317626.3313910.479660.964897.381519.23153.6300000000000
100
000-1095.83-3759.46-6907.47-9201.84-9746.78-9466.23-8930.2-7981.19-6306.74-3551.24-1291.68-98.6700000000000000001550.855625.3910621.7114528.0715726.2415656.1315111.631407611420.16695.162458.08187.770000000000000
Loading...
 
 
 
Convolutions
 
 
Main menu