CNN model why the data is too large?

957 views Asked by At

the error message

the model structure

  • use keras and tensorflow backend
  • use CPU only , memory 128GB
  • input data has the shape (45,1024,1024)
  • the model has only one convolution , one (2,2) max pooling
  • a 1024 *1024 fully connected.

I got this error message:

Invalid argument: Shape [4194304,1048576] is too large (more than 1099511627776 entries)

note that:

4194304 = 2048 * 2048
1048576 = 1024 * 1024

How did keras compute this shape? why is it too large?

1

There are 1 answers

0
Sergii Gryshkevych On BEST ANSWER

The shape [4194304, 1048576] is computed as follows:

Applying 16 convolutions of size [3, 3] with the same border mode to the inputs of size [1024, 1024, 3] gives us output of size [1024, 1024, 16]. After max pooling of size 2 it becomes [512, 512, 16] which when flattened is 512 * 512 * 16 = 4194304. 1048576 comes from 1024 * 1024 as you specified in the Dense layer constructor.

I think you should reconsider the architecture of you model. You can use inputs of smaller size, add several pooling layers, reduce dimensionality applying 1 x 1 convolutions. And I doubt that 1024 * 1024 is a reasonable number of nodes in a fully connected layer.