2
$\begingroup$

Say, I have an image dataset (for example, imagenet) and I am training two image recognition models on it. I train a resnet with 10 layers 3 times on it (each time with different random weight initialization), each time for 20 epochs. For last 5 epochs of training, the accuracy on test datasets does not change very much, but oscillates around. At each of the last 5 epochs, I save the current weights (at that epoch) of the model.

I also have a resnet with 20 layers. Let's say I train it 4 times for 20 epochs on the same dataset, and simiarly save the weights at the final 5 epochs for each training.

I also have 10 test image datasets, coming from various sources, maybe from internet, web cameras, street cameras, screenshots from movies, etc. Each of the the datasets has varying number of images in them, ranging from 20 to 20000.

I evaluate all the models (2*(3+4)*5=70) on all the datasets.

Now given the above info, I have these questions: What is the probability that a resnet with 20 layers is on average better on these datasets than a resnet with 10 layers? (on average, as in calculating the accuracy on each of the ten datasets, and then taking the mean of the ten resultant values). And what are the confidence intervals (or credible intervals) around that probability value?

There are multiple sources of variance here: variance due to test dataset sizes, variance due to different weight initializations, variance due to accuracy oscillating from one epoch to next. How do you account for all these sources of variance to come up with a single number which would indicate the probability that one method is better than the other?

And finally, imagine that you did these tests, and you noticed that on one of the ten datasets the accuracy difference is the largest between these two methods. How can you quantify whether such accuracy difference is by chance or because it indeed is the case that one of the methods is better on this particular dataset? (the concern here is the multiple hypothesis testing and how to account for it, while taking care of all the other sources of variance as well).

$\endgroup$
6
  • $\begingroup$ So to clarify: 6 models, pairs of which are trained on the same data. 10 test results, and you want to know if the difference observed in one test set is due to the models? $\endgroup$ Sep 4, 2020 at 17:55
  • $\begingroup$ Could you maybe show us what kind of results you're working with? $\endgroup$ Sep 4, 2020 at 18:04
  • $\begingroup$ Where did you get your datasets from? $\endgroup$ Sep 4, 2020 at 18:31
  • $\begingroup$ I rewrote the question to be more concrete. $\endgroup$
    – Sunny88
    Sep 4, 2020 at 19:35
  • 1
    $\begingroup$ did you consider multilevel models/generalised least squares? clearly nets don't vary that much between one epoch and the following. $\endgroup$
    – carlo
    Sep 4, 2020 at 19:45

1 Answer 1

1
$\begingroup$

(1) "What is the probability that a resnet with 20 layers is on average better on these datasets than a resnet with 10 layers?" In order to define a probability, you need a probability model. I'm not familiar with resnet, however you list "variance due to test dataset sizes, variance due to different weight initializations". For weight initialisations you'd need to define a probability distribution in order to define the probability that you apparently want. If you can generate weight initialisations randomly using some probability mechanism (and some other input parameters you may want to explore) many times on all datasets (see the last paragraph in (1) for aggregating results over the 10 datasets), you can estimate the probability that resnet(20) is better than resnet (10) on the datasets just by looking at the relative frequencies; and standard Bernoulli/Binomial theory will give you confidence intervals. Of course the probability that you get refers to the specific distribution you used for choosing the input parameters, but without such a specification, no probability can be computed.

One thing that is important here is the question what is random and what is fixed. If you ask whether one method is significantly better than another on dataset X, there is no "variance due to test dataset size", because dataset X has just one size, which is given. The only thing that can be random here are random choices when running the methods. Also, as long as you are only asking what is better "on these datasets" you have just the fixed set of dataset sizes that you have, there is no variation. This is what you asked. If you want to generalise to other datasets, you open a can of worms, because then you'd need to have a distribution of observed datasets drawn randomly from a well defined population, and I don't think you have that (this is why I asked earlier where the datasets are from).

There is also a certain issue with the problem definition. My interpretation here is "what is the probability that resnet(20) is better than resnet(10) if any of the 10 test datasets is randomly drawn", and this means that you should run things so that each time first you draw one of your test datasets at random before running both methods of it. However you may also be interested in something else, for example averaging accuracy differences over the 10 datasets, in which case you need to run each time each analysis on all 10 datasets, compute the accuracy average over all datasets, and record whether this is larger or smaller than zero. Other ways of operationalising this are conceivable.

(2) "How can you quantify whether such accuracy difference is by chance or because it indeed is the case that one of the methods is better on this particular dataset? (the concern here is the multiple hypothesis testing and how to account for it, while taking care of all the other sources of variance as well)."

Here's something important: As I tried to respond to your first question above literally as you asked it, the computation of the probability that resnet(20) is better than resnet (10) on that dataset is not a p-value, and what was done there was not a hypothesis test! A hypothesis test addresses the question: "How likely is it, under some null hypothesis (here probably "methods are equally good"), that a certain test statistic comparing results is as large or larger than what was actually observed, to make statements about to what extent the data are compatible with the null model. This means that a test will tell you how likely a value of a statistic is, assuming methods are equal, whereas what you asked was "how likely is it that one method is better than the other", which is a different question. This means that if you follow my response to (1), you don't actually run multiple tests.

One possibility to address the second question, assuming that there are in fact only random differences between methods, is using a permutation test.

(a) Run many replicates of analyses with both methods as explained in (1) on all 10 datasets.

(b) For every dataset, randomly permute results and assign a random sample of half of them to method 1 and the other half to method 2. Record the accuracy differences. Also record each time the maximum accuracy difference over all 10 datasets. If you run, say, 1000 replicates, you obtain a dataset of 1000 maximum accuracy differences.

(c) The relative frequency of those that are bigger than what you actually observed gives you a permutation p-value testing the null hypothesis that the two methods only differ randomly, i.e., if this is very small, it is evidence that your observed maximum accuracy difference is actually meaningful and the better method is properly better on at least that dataset.

(By the way, you can do the same thing on any single dataset to have test p-values for any specific dataset, if this is what you want more than what I had explained in (1).)

$\endgroup$
7
  • $\begingroup$ I might be wrong, but in general neural networks output decisions, not probabilities. You propose that the OP might check which net is better just by the relative frequencies, but since NNs are essencially black boxes, how do you propose they create the probability model for each neuron? $\endgroup$
    – LmnICE
    Sep 9, 2020 at 13:41
  • 1
    $\begingroup$ @LmnICE You are incorrect. A neural network in a "classification" problem outputs a probability of class membership. It is then up to the operator (engineer, analyst...) to make a decision based on that probability. There are defaults in software, typically a threshold of $0.5$ for a binary classification, but you do not have to let the software default tell you what to do. After all, what if the software default were $0.9$ because the Sarek software developer was born in September and $9$ is her lucky number? (Sarek is Keras backwards.) $\endgroup$
    – Dave
    Sep 10, 2020 at 14:04
  • 1
    $\begingroup$ Please refer to Kolassa's answer to this question, as well as the links within (and the links in those, especially Frank Harrell's blog posts). $\endgroup$
    – Dave
    Sep 10, 2020 at 14:07
  • $\begingroup$ @Dave TIL, thanks. I think my point still stands, though. The problem of creating the probability model for each neuron seems to me to be quite complex. In fact, even more complex when you factor in the decision of which thresholds to use, no? $\endgroup$
    – LmnICE
    Sep 10, 2020 at 14:18
  • $\begingroup$ Maybe I should include the link I said to read... stats.stackexchange.com/questions/464636/… $\endgroup$
    – Dave
    Sep 10, 2020 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.