title: What is the memory size for convolutional neural networks?
body: <p>I am looking at <a href="http://cs231n.github.io/convolutional-networks/" rel="nofollow">http://cs231n.github.io/convolutional-networks/</a></p>
  
  <p>I don't understand why the memory size of layer 2 (CONV3-64: [224x224x64]) is 224x224x<strong>64</strong></p>
  
  <ol>
  <li>I understand that there are 64 filters of size 3x3 but why is the input size multiplied by 64?</li>
  <li>Why the number of weights in layer (CONV3-128) are (3x3x64)x128 and not 
  (3x3x64x64)x128 ? (the weights from the previous layer times the new 128 filters)</li>
  </ol>
  
  <p>Thanks</p>
  
  <pre><code>INPUT: [224x224x3]        memory:  224*224*3=150K   weights: 0
  CONV3-64: [224x224x64]  memory:  224*224*64=3.2M   weights: (3*3*3)*64 = 1,728
  CONV3-64: [224x224x64]  memory:  224*224*64=3.2M   weights: (3*3*64)*64 = 36,864
  POOL2: [112x112x64]  memory:  112*112*64=800K   weights: 0
  CONV3-128: [112x112x128]  memory:  112*112*128=1.6M   weights: (3*3*64)*128 = 73,728
  CONV3-128: [112x112x128]  memory:  112*112*128=1.6M   weights: (3*3*128)*128 = 147,456
  POOL2: [56x56x128]  memory:  56*56*128=400K   weights: 0
  CONV3-256: [56x56x256]  memory:  56*56*256=800K   weights: (3*3*128)*256 = 294,912
  CONV3-256: [56x56x256]  memory:  56*56*256=800K   weights: (3*3*256)*256 = 589,824
  CONV3-256: [56x56x256]  memory:  56*56*256=800K   weights: (3*3*256)*256 = 589,824
  POOL2: [28x28x256]  memory:  28*28*256=200K   weights: 0
  CONV3-512: [28x28x512]  memory:  28*28*512=400K   weights: (3*3*256)*512 = 1,179,648
  CONV3-512: [28x28x512]  memory:  28*28*512=400K   weights: (3*3*512)*512 = 2,359,296
  CONV3-512: [28x28x512]  memory:  28*28*512=400K   weights: (3*3*512)*512 = 2,359,296
  POOL2: [14x14x512]  memory:  14*14*512=100K   weights: 0
  CONV3-512: [14x14x512]  memory:  14*14*512=100K   weights: (3*3*512)*512 = 2,359,296
  CONV3-512: [14x14x512]  memory:  14*14*512=100K   weights: (3*3*512)*512 = 2,359,296
  CONV3-512: [14x14x512]  memory:  14*14*512=100K   weights: (3*3*512)*512 = 2,359,296
  POOL2: [7x7x512]  memory:  7*7*512=25K  weights: 0
  FC: [1x1x4096]  memory:  4096  weights: 7*7*512*4096 = 102,760,448
  FC: [1x1x4096]  memory:  4096  weights: 4096*4096 = 16,777,216
  FC: [1x1x1000]  memory:  1000 weights: 4096*1000 = 4,096,000
  
  TOTAL memory: 24M * 4 bytes ~= 93MB / image (only forward! ~*2 for bwd)
  TOTAL params: 138M parameters
  </code></pre>