1
$\begingroup$

Let's say, for example, I have built the following CNN model using Keras:

model = Sequential()
model.add(Conv2D(32, (3,3), activation='relu', input_shape=(32,32,3)))
model.add(MaxPooling2D((2, 2)))
model.add(Conv2D(32, (3,3), activation='relu'))
model.add(MaxPooling2D((2, 2)))
model.add(Flatten())
model.add(Dense(512))
model.add(Dense(10, activation='softmax'))

I wish to be able to transform the above model into a mathematical formula.


I understand the basic structure of a CNN as follows:

CNN recursive formula

where

definitions for used values enter image description here


However, I do not know how to go from the above recursive formula to something like this (the first two summations are weights and the second two are adjustable biases):

enter image description here

Note: The formula above is just an example and not representative of the code given above.


  • Do I need to trace each weight, each bias and each connection of every neuron? If so, how?
  • Furthermore, I would highly appreciate it if someone could provide a generalized strategy for tackling such a problem (like finding a math formula to suit a different kind of classifier).
  • Lastly, is this an easy task and is it a worthwhile one?

Note: This question was originally posted on Stack Overflow. Unfortunately, I received no responses even after offering a bounty. Hence, I am uploading the question here. Link to the original post here.

$\endgroup$
2
  • 1
    $\begingroup$ You can unroll the recursion, but it won't simplify much (if at all), as it is based on non-linear function composition, e.g. $y=f(g(h(i(j(x)))))$ where each of $f()$, $g()$ etc represents the function of a single layer. That's one of the main points for having layers - if there was something simpler possible, then deeper neural networks would not be as useful. $\endgroup$ Jul 19 at 9:56
  • $\begingroup$ @NeilSlater That makes sense, thanks! $\endgroup$ Jul 19 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.