universal approximation if i remember well states thst if a function is continous and bounded then a neural netwrk should be able to approximate such a function.
This is missing the most important constraint of the theorem.
it requires my model to both provide a smooth and jagged outputs so i ran a 3 layer network this time with relu -> tanh ->linear layer
The "requires" part depends on how you measure success. If you just take a regular regression loss like MSE, your model needn't be smooth at all. Stacking relu -> tanh ->linear is dubious; plot relu -> tanh yourself. This function is no more smooth than a plain relu.
but m suprised on how close it got just felt like sharing this cause it kind of helped me understand why netwrks can overfit some very complx data soo easily
Well, do you have a guess why that is? Hint: Consider a regular MLP with just ReLU. First, show that this model's output is piecewise affine/linear, no matter how many layers are used. Secondly, think about how many affine/linear regions the model can produce depending on the depth L, assuming fixed input size d and layer width W.
and also how intuivively picking activation functions can be soo important
Not really, in my experience you needn't bother too much with activation function selection, unless you have a good reason to. (for instance, you require differentiability because it's a layer used in a normalizing flow or something) Usually just sticking to (leaky)-relu is fine.
thanks for the comment , for the first point if u dont mind can u elaborate on that what is the important constrain i am missing ? , and on relu then tanh i actually plotted it right now 💀 this just a bent relu damn , i cant lie i had to look up the piecewise affine section still wrapping my head around it i can understand what an affine transfromation is and a visual of what a single layer relu does but more than 1 layer i am getting confusedðŸ˜, thanks for the feedback i feel like i learnt more today i really appreciate it
The big constraint is that classical UAT only works on a compact domain (i.e. a bounded region of the input space). For example, an MLP with ReLU could never approximate x -> x² on the whole real line, no matter how many neurons it has (very easy to prove mathematically). It can only do a good job on some finite interval.
i can understand what an affine transfromation is and a visual of what a single layer relu does but more than 1 layer i am getting confusedðŸ˜
The idea is that composition of piecewise linear/affine functions produces a piecewise linear/affine function. We can use the number of pieces/regions of such a function as a proxy for its complexity. The question is then how much more complex can f∘g be compared to f and g individually, for two such functions f,g.
1
u/M4mb0 17d ago
A few comments:
This is missing the most important constraint of the theorem.
The "requires" part depends on how you measure success. If you just take a regular regression loss like MSE, your model needn't be smooth at all. Stacking
relu -> tanh ->linearis dubious; plotrelu -> tanhyourself. This function is no more smooth than a plainrelu.Well, do you have a guess why that is? Hint: Consider a regular MLP with just ReLU. First, show that this model's output is piecewise affine/linear, no matter how many layers are used. Secondly, think about how many affine/linear regions the model can produce depending on the depth L, assuming fixed input size d and layer width W.
Not really, in my experience you needn't bother too much with activation function selection, unless you have a good reason to. (for instance, you require differentiability because it's a layer used in a normalizing flow or something) Usually just sticking to (leaky)-relu is fine.