4
$\begingroup$

Is it possible to estimate the capacity of a neural network model? If so, what are the techniques involved?

$\endgroup$
  • $\begingroup$ What is capacity though? I think it is dependent on dataset too...If the dataset is linearly separable a small NN will easily work, which might not be the case for complex datasets which are not linearly separable. On the same note a NN can approximate a bounded function so a simple ML model like $a_0 + a_1 x^3$ might trump a NN in regression type tasks. So I think we need to define what kind of capacity are you talking about. Like in bounded or unbounded dataset, is there any constraints, etc. $\endgroup$ – DuttaA Feb 6 at 5:05
  • $\begingroup$ Adding on to DuttaA, what exactly do you mean by capacity? Is it the accuracy or the inference speed? There is a trade-off involved in deciding which is important. $\endgroup$ – Sharan Feb 6 at 7:35
  • $\begingroup$ It needs to be mentioned that when it comes to neural networks, VC dimension is a terrible way to measure capacity. $\endgroup$ – Anon Jul 26 at 2:56
3
$\begingroup$

The VC dimension

The most common and rigorous measure of the capacity of a neural network is the VC dimension, which is intuitively a number or bound that quantifies the difficulty of learning from data. The sample complexity, which is the number of training instances that the model (or learner) must be exposed to in order to be reasonably certain of the accurateness of the predictions made given some data, is proportional to this number.

The paper VC Dimension of Neural Networks by Eduardo D. Sontag provides a good introduction to the VC dimension of neural networks (even though these concepts are quite abstract and you may need to read them several times to fully grasp them). The information in this answer is highly based on that paper.

Shattering and VC dimension

In section 2, Concepts and VC Dimension, he describes the basic concepts behind the VC dimension (not only for neural networks), such as the concept of shattering (i.e. what does it mean for a set of sets to shatter another set?), which is a well-known concept in computational learning theory and is used to define the VC dimension (see definition 2), so you definitely need to get familiar with this concept to understand the VC dimension and, therefore, the capacity of a neural network (calculated with the VC dimension).

VC dimension of functions and neural networks

He then provides an equivalent definition of the VC dimension but for functions (equation 6). Given that neural networks represent functions, then we can also define the VC dimension of a neural network. A specific combination of weights of neural networks represents a specific function, for which the VC dimension can be defined. To be more precise, a parametrized function (and a neural network) can be denoted as

$$ \beta : \mathbb{W} \times \mathbb{U} \rightarrow \mathbb{R} $$

where $\mathbb{W} = \mathbb{R}^p$ and $p$ is the number of weights (or parameters) of the neural network, $\mathbb{U}$ is the input space and $\mathbb{R}$ the output space. So, in this case, $\beta$ can also represent a neural network, with a certain parameter space $\mathbb{W}$, an input space $\mathbb{U}$ and an output space $\mathbb{R}$.

The vector $\mathbf{w} = (w_1, \dots, w_p) \in \mathbb{W}$ represents a specific combination of weights of the neural network, so it represents a specific function. The set of all functions for each choice of this weight vector can be denoted as

$$ \mathcal{F}_{\beta} = \{ \beta(\mathbf{w}, \cdot) \mid \mathbf{w} \in \mathbb{W} \} $$

The VC dimension (VCD) of $\beta$ can then be defined as

$$ \text{VCD}(\beta) := \text{VCD}(\mathcal{F}_{\beta}) $$

Therefore, the VC dimension is a measure of the capacity of a neural network with a certain architecture. And it is equivalently defined for a certain set of functions associated with a neural network.

How to calculate the VC dimension?

To calculate the actual VC dimension of a neural network, it takes a little bit of more creativity. Therefore, I will just report the VC dimension of some neural networks. For more details, you should fully read the cited paper (more than once) and other papers and books too (especially, the ones described in this answer, which provide an introduction to CLT concepts).

VC dimension of a perceptron

The VC dimension of a perceptron is $m + 1$, where $m$ is the number of inputs. Given that a perceptron represents a linear and affine function, the VC dimension of the perceptron is also equal to the number of parameters. However, note that, even though the VC dimension of the perceptron is linear in the number of parameters and inputs, it doesn't mean the perceptron can learn any function. In fact, perceptrons can only represent linear functions. See section 3.1 of VC Dimension of Neural Networks for more details.

VC dimension of a single hidden layer neural network

Let $n$ be the number of hidden units, then the VC dimension of a single hidden layer neural network is less than or equal to $n+1$. See section 3.2 of VC Dimension of Neural Networks for more details.

VC dimension of multi-layer neural networks with binary activations

The VC dimension of multi-layer neural networks (MLPs) with binary activations and $p$ weights (or parameters) is $\mathcal{O}(p \log p)$. See theorem 4 (and related sections) of the paper VC Dimension of Neural Networks for more details.

VC dimension of MLPs with real-valued activations

The VC dimension of MLPs with real-valued activations is no longer bounded by $\mathcal{O}(p \log p)$ and can be exponential in the number of parameters. See section 5.3 of VC Dimension of Neural Networks.

VC dimension of MLPs with linear activations

The VC dimension of MLPs with linear activations is $\mathcal{O}(p^2)$. See theorem 5 of the paper VC Dimension of Neural Networks.

Conclusions

  • The VC dimension of a neural network depends on the architecture (e.g. the number of layers and number of units per layer)
  • The basic concepts of CLT, such as the concept of shattering, hypothesis space, set of sets, etc., are fundamental to understanding the concept of the VC dimension.
  • The calculation of the VC dimension requires some creativity
  • Given that the VC dimension can often be defined as a function of the number of parameters, people usually associated the number of parameters with the capacity of the network, even though the specific relationship may be slightly more complex than something like "the capacity of this neural network is roughly equal to the double of the number of weights".
  • The VC dimension can be used to provide bounds on the number of samples required to learn a certain task.
  • The VC dimension is often expressed as a bound (e.g. with big-O notation), which may not be strict

Conclusion

The capacity of a neural network is related to the number of functions it can represent, the generalization ability of the neural network and how efficiently it can learn a function given some data. Therefore, computational learning theory (and, in particular, statistical learning theory) is the area of study you should follow in order to learn more about the capacity of neural networks.

The VC dimension is a rigorous definition of the capacity of a neural network. However, note that the VC dimension is often expressed as a bound (e.g. with big-O notation), which may not be strict. In any case, the VC dimension is useful because it provides some guarantees. For example, if you use the VC dimension to describe an upper bound on the number of samples required to learn a certain task, then you have a precise mathematical formula that guarantees that you will not need more samples than those expressed by the bound in order to achieve a small generalization error, but, in practice, you may need fewer samples than those expressed by the bound (because these bounds may not be strict or the VC dimension may also not be strict).

Beyond the VC dimension

Although I am aware of the existence of other ways of calculating the capacity of a neural network, I am not yet familiar with them. Anyway, you may be interested in papers such as On Characterizing the Capacity of Neural Networks using Algebraic Topology. See also section 6, Algebraic Techniques, of the paper I have been citing: VC Dimension of Neural Networks

The capacity of a neural network is clearly related to the number of functions it can represent, so it is strictly related to the universal approximation theorems for neural networks. See Where can I find the proof of the universal approximation theorem?.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Comments are not for extended discussion; this conversation has been moved to chat. $\endgroup$ – nbro Mar 7 at 17:46
1
$\begingroup$

Most methods for measuring the complexity of neural networks are fairly crude. One common measure of complexity is VC dimension, a discussion which can be found here and here. For example, neural networks have a VC dimension that is too large to give a strong upper bound on the number of training samples needed for a model (the upper bound provided by VC analysis is much higher than what we have observed neural networks to be able to generalize from).

Another common measure of capacity is the number of parameters. We see in the paper "Understanding deep learning requires rethinking generalization", published at ICLR with over 1400+ citations, that networks with more parameters than data often have the capacity to memorize the data. The paper provides compelling evidence that traditional approaches to generalization provided by statistical learning theory (VC dimension, Rademacher complexity) are unable to fully explain the apparent capacity of neural networks. In general, neural networks seem to have a large capacity, given the apparent good performance on certain tasks.

Beyond these ideas, the universal approximation theorem tells us that the set of neural networks can approximate any continuous function arbitrarily well, which strongly suggests that any neural network has a large capacity.

| improve this answer | |
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.