title: Memory problem when adding dense layer to CNN
body: <p>I am implementing my first CNN in Tensorflow and I am having trouble when adding the dense layer to my CNN model. Here is the code:</p>
  <pre><code>batch_size = 4
  sample_shape = (batch_size, 24, 30, 30, 5)
  
  model = models.Sequential()
  model.add(layers.Conv3D(96, kernel_size=(4, 4, 4), activation='relu', padding='same', input_shape=sample_shape))
  model.add(layers.Conv3D(64, kernel_size=(3, 3, 3), activation='relu', padding='same'))
  model.add(layers.Conv3D(64, kernel_size=(1, 1, 5), activation='relu', padding='same'))
  model.add(layers.Flatten())
  model.add(layers.Dense(256, activation='relu'))
  
  model.summary()
  </code></pre>
  <p>I am getting the following output. Later, my program crashes. What needs so much memory? It seems to be the Dense Layer, but I can't explain it.</p>
  <pre><code>2021-10-20 19:03:53.219849: W tensorflow/core/framework/cpu_allocator_impl.cc:80] Allocation of 5662310400 exceeds 10% of free system memory.
  </code></pre>