|
1 |
| -# RF_calculator |
| 1 | +## This Project can help you calculating Receptive Field in every layer for CNN model ## |
| 2 | + |
| 3 | +# How to use ? |
| 4 | +```python |
| 5 | +!pip install rf-calc |
| 6 | + |
| 7 | + |
| 8 | +from rf_calc import receptive_field |
| 9 | +model = models.GoogLeNet().to(device) |
| 10 | +image_input_size = 224 |
| 11 | +RF = receptive_field(model,image_input_size) |
| 12 | +``` |
| 13 | + |
| 14 | +# Output |
| 15 | +```python |
| 16 | +Kernel_size : Size of the convolving kernel. |
| 17 | +Padding : Zero-padding added to both sides of the input image. |
| 18 | +Stride : Stride of the convolution. Default: 1 |
| 19 | +Input_Img_size : Shape of image as input to the layer. |
| 20 | +Output_Img_size : Shape of image as Output from the layer. |
| 21 | +Receptive_field : Shape pf Receptive field in the layer. |
| 22 | + |
| 23 | +=======================================Reciptive Field Calculator======================================== |
| 24 | +| | Kernel_size | Padding | Stride | Input_Img_size | Output_Img_size | Receptive_field | |
| 25 | +|---:|:--------------|:----------|---------:|:-----------------|:------------------|:------------------| |
| 26 | +| 0 | 7*7 | 3 | 2 | 224*224 | 112*112 | 7*7 | |
| 27 | +| 1 | 3*3 | NO | 2 | 112*112 | 55*55 | 11*11 | |
| 28 | +| 2 | 1*1 | NO | 1 | 55*55 | 55*55 | 11*11 | |
| 29 | +| 3 | 3*3 | 1 | 1 | 55*55 | 55*55 | 19*19 | |
| 30 | +| 4 | 3*3 | NO | 2 | 55*55 | 27*27 | 27*27 | |
| 31 | +| 5 | 1*1 | NO | 1 | 27*27 | 27*27 | 27*27 | |
| 32 | +| 6 | 1*1 | NO | 1 | 27*27 | 27*27 | 27*27 | |
| 33 | +| 7 | 3*3 | 1 | 1 | 27*27 | 27*27 | 43*43 | |
| 34 | +| 8 | 1*1 | NO | 1 | 27*27 | 27*27 | 43*43 | |
| 35 | +| 9 | 3*3 | 1 | 1 | 27*27 | 27*27 | 59*59 | |
| 36 | +| 10 | 3*3 | 1 | 1 | 27*27 | 27*27 | 75*75 | |
| 37 | +| 11 | 1*1 | NO | 1 | 27*27 | 27*27 | 75*75 | |
| 38 | +| 12 | 1*1 | NO | 1 | 27*27 | 27*27 | 75*75 | |
| 39 | +| 13 | 1*1 | NO | 1 | 27*27 | 27*27 | 75*75 | |
| 40 | +| 14 | 3*3 | 1 | 1 | 27*27 | 27*27 | 91*91 | |
| 41 | +| 15 | 1*1 | NO | 1 | 27*27 | 27*27 | 91*91 | |
| 42 | +| 16 | 3*3 | 1 | 1 | 27*27 | 27*27 | 107*107 | |
| 43 | +| 17 | 3*3 | 1 | 1 | 27*27 | 27*27 | 123*123 | |
| 44 | +| 18 | 1*1 | NO | 1 | 27*27 | 27*27 | 123*123 | |
| 45 | +| 19 | 3*3 | NO | 2 | 27*27 | 13*13 | 139*139 | |
| 46 | +| 20 | 1*1 | NO | 1 | 13*13 | 13*13 | 139*139 | |
| 47 | +| 21 | 1*1 | NO | 1 | 13*13 | 13*13 | 139*139 | |
| 48 | +| 22 | 3*3 | 1 | 1 | 13*13 | 13*13 | 171*171 | |
| 49 | +| 23 | 1*1 | NO | 1 | 13*13 | 13*13 | 171*171 | |
| 50 | +| 24 | 3*3 | 1 | 1 | 13*13 | 13*13 | 203*203 | |
| 51 | +| 25 | 3*3 | 1 | 1 | 13*13 | 13*13 | 235*235 | |
| 52 | +| 26 | 1*1 | NO | 1 | 13*13 | 13*13 | 235*235 | |
| 53 | +| 27 | 1*1 | NO | 1 | 13*13 | 13*13 | 235*235 | |
| 54 | +| 28 | 1*1 | NO | 1 | 13*13 | 13*13 | 235*235 | |
| 55 | +| 29 | 3*3 | 1 | 1 | 13*13 | 13*13 | 267*267 | |
| 56 | +| 30 | 1*1 | NO | 1 | 13*13 | 13*13 | 267*267 | |
| 57 | +| 31 | 3*3 | 1 | 1 | 13*13 | 13*13 | 299*299 | |
| 58 | +| 32 | 3*3 | 1 | 1 | 13*13 | 13*13 | 331*331 | |
| 59 | +| 33 | 1*1 | NO | 1 | 13*13 | 13*13 | 331*331 | |
| 60 | +| 34 | 1*1 | NO | 1 | 13*13 | 13*13 | 331*331 | |
| 61 | +| 35 | 1*1 | NO | 1 | 13*13 | 13*13 | 331*331 | |
| 62 | +| 36 | 3*3 | 1 | 1 | 13*13 | 13*13 | 363*363 | |
| 63 | +| 37 | 1*1 | NO | 1 | 13*13 | 13*13 | 363*363 | |
| 64 | +| 38 | 3*3 | 1 | 1 | 13*13 | 13*13 | 395*395 | |
| 65 | +| 39 | 3*3 | 1 | 1 | 13*13 | 13*13 | 427*427 | |
| 66 | +| 40 | 1*1 | NO | 1 | 13*13 | 13*13 | 427*427 | |
| 67 | +| 41 | 1*1 | NO | 1 | 13*13 | 13*13 | 427*427 | |
| 68 | +| 42 | 1*1 | NO | 1 | 13*13 | 13*13 | 427*427 | |
| 69 | +| 43 | 3*3 | 1 | 1 | 13*13 | 13*13 | 459*459 | |
| 70 | +| 44 | 1*1 | NO | 1 | 13*13 | 13*13 | 459*459 | |
| 71 | +| 45 | 3*3 | 1 | 1 | 13*13 | 13*13 | 491*491 | |
| 72 | +| 46 | 3*3 | 1 | 1 | 13*13 | 13*13 | 523*523 | |
| 73 | +| 47 | 1*1 | NO | 1 | 13*13 | 13*13 | 523*523 | |
| 74 | +| 48 | 1*1 | NO | 1 | 13*13 | 13*13 | 523*523 | |
| 75 | +| 49 | 1*1 | NO | 1 | 13*13 | 13*13 | 523*523 | |
| 76 | +| 50 | 3*3 | 1 | 1 | 13*13 | 13*13 | 555*555 | |
| 77 | +| 51 | 1*1 | NO | 1 | 13*13 | 13*13 | 555*555 | |
| 78 | +| 52 | 3*3 | 1 | 1 | 13*13 | 13*13 | 587*587 | |
| 79 | +| 53 | 3*3 | 1 | 1 | 13*13 | 13*13 | 619*619 | |
| 80 | +| 54 | 1*1 | NO | 1 | 13*13 | 13*13 | 619*619 | |
| 81 | +| 55 | 2*2 | NO | 2 | 13*13 | 6*6 | 635*635 | |
| 82 | +| 56 | 1*1 | NO | 1 | 6*6 | 6*6 | 635*635 | |
| 83 | +| 57 | 1*1 | NO | 1 | 6*6 | 6*6 | 635*635 | |
| 84 | +| 58 | 3*3 | 1 | 1 | 6*6 | 6*6 | 699*699 | |
| 85 | +| 59 | 1*1 | NO | 1 | 6*6 | 6*6 | 699*699 | |
| 86 | +| 60 | 3*3 | 1 | 1 | 6*6 | 6*6 | 763*763 | |
| 87 | +| 61 | 3*3 | 1 | 1 | 6*6 | 6*6 | 827*827 | |
| 88 | +| 62 | 1*1 | NO | 1 | 6*6 | 6*6 | 827*827 | |
| 89 | +| 63 | 1*1 | NO | 1 | 6*6 | 6*6 | 827*827 | |
| 90 | +| 64 | 1*1 | NO | 1 | 6*6 | 6*6 | 827*827 | |
| 91 | +| 65 | 3*3 | 1 | 1 | 6*6 | 6*6 | 891*891 | |
| 92 | +| 66 | 1*1 | NO | 1 | 6*6 | 6*6 | 891*891 | |
| 93 | +| 67 | 3*3 | 1 | 1 | 6*6 | 6*6 | 955*955 | |
| 94 | +| 68 | 3*3 | 1 | 1 | 6*6 | 6*6 | 1019*1019 | |
| 95 | +| 69 | 1*1 | NO | 1 | 6*6 | 6*6 | 1019*1019 | |
| 96 | +| 70 | 1*1 | NO | 1 | 6*6 | 6*6 | 1019*1019 | |
| 97 | +| 71 | 1*1 | NO | 1 | 6*6 | 6*6 | 1019*1019 | |
| 98 | +========================================================================================================= |
| 99 | +``` |
| 100 | + |
| 101 | +# About Receptive Field |
| 102 | + |
| 103 | +What is Receptive Field ? |
| 104 | + |
| 105 | +1> Local Receptive field |
| 106 | +Local receptive field is present in every layer. Local receptive will be the size of kernel used in the layer .For example if we have an image of size 19x19 and we are applying a 3x3 metric then local receptive field will be 3x3 in first layer. |
| 107 | + |
| 108 | +2> Global Receptive field |
| 109 | +At every layer the part of image our kernel can see is global receptive field .For a 3x3 kernel convolution global receptive field will increase by 2 units ( there is a mathematical formula that we can cover in later chapters ). It means if you see the below code in every convolution step our model will be able to see 2 pixel more in each side of image . |
| 110 | + |
| 111 | + |
| 112 | +Input image => kernel shape => Output Image -> local Receptive field -> Global Receptive field |
| 113 | +19x19 => 3x3 => 17x17 -> 3x3 ->3x3 |
| 114 | +17x17 => 3x3 => 15x15 ->3x3 ->5x5 |
| 115 | +15x15 => 3x3 => 13x13 ->3x3 ->7x7 |
| 116 | +13x13 => 3x3 => 11x11 ->3x3 ->9x9 |
| 117 | +11x11 => 3x3 => 9x9 ->3x3 ->11x11 |
| 118 | +9x9 => 3x3 => 7x7 ->3x3 ->13x13 |
| 119 | +7x7 => 3x3 => 5x5 ->3x3 ->15x15 |
| 120 | +5x5 => 3x3 => 3x3 ->3x3 ->17x17 |
| 121 | +3x3 => 3x3 => 1x1 ->3x3 ->19x19 |
| 122 | + |
| 123 | +Read the article for better understanding. |
| 124 | +https://medium.com/@data.pruthiraj/building-blocks-of-computer-vision-and-cnn-f5acdbf3c0b7 |
0 commit comments