Answers.Body: <p>Adding on top of Chillston answer:</p>
  <p>regarding the variance, it is unfortunately not so straight forward. The problem being that most deep learning models are not <a href="https://scikit-learn.org/stable/modules/calibration.html" rel="nofollow noreferrer">calibrated</a>, hence small intra-class variation might lead to large probability variations for the winning class. Maybe one way to account for this issue would be to compute the <a href="https://en.wikipedia.org/wiki/Mutual_information" rel="nofollow noreferrer">mutual information</a> between the generated predictions and a prior expected distribution, for example uniform probability distribution 1/n with n number of expected difference within class, like horse poses to use the same example as Chillstone, but I found no reference about similar attempts, plus coming up with a proper prior expected distribution doesn't sound trivial at all. I guess the reason is that the inception score was designed for generic GANs (i.e. GANs trained to generate generic classes from CIFAR and similar dataset) so without having in mind to measure variability within classes.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-06T16:00:21.447Z
Answers.Text: That's a good point - Inception is trained to be invariant to intra-class variations, so to capture this a different model or at least a differently trained inception model might be better suited. Maybe something that identifies data transformations like Capsule Net
Answers.UserDisplayName: Chillston
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-07T12:31:56.830Z
Answers.Text: "small intra-class variation might lead to large probability variations for the winning class" is a weird concept to me, but I've seen this several times. Isn't the function output = f(input) continuous with regards to the input?
Answers.UserDisplayName: FluidMechanics Potential Flows
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-07T13:31:07.243Z
Answers.Text: not sure if I'm missing something, but the continuity of the final activation function doesn't tell you much about the properties of the function learned by a  classifier.
Answers.UserDisplayName: Edoardo Guerriero
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-08T18:48:13.310Z
Answers.Text: @EdoardoGuerriero All the functions are continuous right? The last activation function is, the one to get from layer n-1 to n is too, etc.?
Answers.UserDisplayName: FluidMechanics Potential Flows
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-08T20:46:02.103Z
Answers.Text: sure, but again continuity doesn't imply strong constrains. The final mapping learn by a classifier is highly non linear, hence it's not surprising (even though undesired in many situations) that small changes can lad to big differences in predictions.
Answers.UserDisplayName: Edoardo Guerriero
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-08T21:39:38.400Z
Answers.Text: Fair enough, isn't there some way to force the behaviour: small changes in the input -> small changes in the output? By integrating this into the loss or maybe by training n networks and picking the one that shows the behaviour the most out of the n networks if they all converge to similar but not same local minima?
Answers.UserDisplayName: FluidMechanics Potential Flows
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-09T07:12:00.853Z
Answers.Text: the problem here is how to numerically define "small change". A topic that kinda fit in this discussion but limited to CNN is [shift invariance](https://arxiv.org/abs/2011.14214), in which people try to solve the issue of CNN misclassifying images that are shifted by a few or just one pixel in one direction. That's already a way to force a model to behave constantly with respect to a predefined small change.
Answers.UserDisplayName: Edoardo Guerriero
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-09T07:17:19.583Z
Answers.Text: another problem, a more conceptual one, is that in general we do want to learn some big changes for small input differences. It's the trade off between generalization and overfitting. So I guess that what would be required to train such a a model is actually a proper dataset. And indeed a custom loss, with an extra error component that compare for example the probability returned for a class with the expected probability we want to observe for each element belonging to that class.
Answers.UserDisplayName: Edoardo Guerriero
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-09T09:38:05.587Z
Answers.Text: Just adding to some comments, I would think that in general, a classification model might not be the best type of model to use for intra-class variations, because its task is to be invariant to those. It always output the same result even though two horses look very different. As a general idea, maybe using a VAE model would be more suitable, as these models are build to capture as much detail as possible, right? Still experiments would have to show if this is feasible to use as a score metric like the inception model.
Answers.UserDisplayName: Chillston
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-06T14:55:05.250Z
Answers.LastActivityDate: 2022-05-06T14:55:05.250Z
Answers.UserDisplayName: Edoardo Guerriero
Answers.Body: <p><strong>For reference, a recap of Inception Score:</strong>
  The inception score is computed by comparing the categorical output distributions of an inception model, given examples from real vs synthetic images. If the synthetic images produce similar class distributions as the real images, the inception score is high, otherwise it is low.</p>
  <blockquote>
  <p>However, isn't it &quot;easy&quot; to look at the variance of the outputs of the classifier for a given class</p>
  </blockquote>
  <p>Say you want to generate multiple horses and the model learns to generate horses with different colors but always in the same pose - then your class probabilities will vary, but I wouldn't call this very diverse horse generation. This is how I would understand what is meant by your cited statement.</p>
  <p>The output distributions from the inception model contain class information but very little information of specific image features. Thus, the inception score cannot be sensitive to intra-class variations of the generator.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-07T12:30:55.143Z
Answers.Text: "multiple horses and the model learns to generate horses with different colors but always in the same pose", yes you're right, I haven't thought of that, variance of the output's classifier would then vary but there isn't as much variability as we'd expect
Answers.UserDisplayName: FluidMechanics Potential Flows
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-06T14:30:06.723Z
Answers.LastActivityDate: 2022-05-06T14:30:06.723Z
Answers.UserDisplayName: Chillston
Body: <p>It's mentioned <a href="https://medium.com/octavian-ai/a-simple-explanation-of-the-inception-score-372dff6a8c7a" rel="nofollow noreferrer">here</a> that there is no measure of intra-class diversity with the inception score:</p>
  <blockquote>
  <p>If your generator generates only one image per classifier image class,
  repeating each image many times, it can score highly (i.e. there is no
  measure of intra-class diversity)</p>
  </blockquote>
  <p>However, isn't it &quot;easy&quot; to look at the variance of the outputs of the classifier for a given class (e.g. if you only output 0.97 for all the images of your GAN class then there is no intra-class diversity but if you output 0.97, 0.95, 0.99, 0.92, there is diversity?). I'm struggling to understand why this is hard to do (but I might be missing something!).</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-06T10:11:52.407Z
Comments.Text: Can you please put your **specific question** in the title? I understand that you're confused about the inception score and how it is related to "intra-class diversity" (whatever that really means), but that is not a question. A question is something like "Why doesn't the inception score ...?"
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-06T13:48:30.690Z
Comments.Text: Done! I edited my the post.
Comments.UserDisplayName: FluidMechanics Potential Flows
Tags: <generative-adversarial-networks><inception>
Title: Why doesn't the inception score measure intra-class diversity
UserDisplayName: FluidMechanics Potential Flows
ThreadText: # Why doesn't the inception score measure intra-class diversity
  
  (Asked by: username_0 on 2022-05-05)
  
  It's mentioned [here](https://medium.com/octavian-ai/a-simple-explanation-of-the-inception-score-372dff6a8c7a) that there is no measure of intra-class diversity with the inception score:
  
  > If your generator generates only one image per classifier image class,
  > repeating each image many times, it can score highly (i.e. there is no
  > measure of intra-class diversity)
  
  However, isn't it "easy" to look at the variance of the outputs of the classifier for a given class (e.g. if you only output 0.97 for all the images of your GAN class then there is no intra-class diversity but if you output 0.97, 0.95, 0.99, 0.92, there is diversity?). I'm struggling to understand why this is hard to do (but I might be missing something!).
  
  **Tags:** generative-adversarial-networks, inception
  
  > **Comments:**
  > **username_1**: Can you please put your **specific question** in the title? I understand that you're confused about the inception score and how it is related to "intra-class diversity" (whatever that really means), but that is not a question. A question is something like "Why doesn't the inception score ...?"  
  > **username_0**: Done! I edited my the post.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2022-05-06. Score: 4 | Accepted answer
  
  **For reference, a recap of Inception Score:**
  The inception score is computed by comparing the categorical output distributions of an inception model, given examples from real vs synthetic images. If the synthetic images produce similar class distributions as the real images, the inception score is high, otherwise it is low.
  
  > However, isn't it "easy" to look at the variance of the outputs of the classifier for a given class
  
  Say you want to generate multiple horses and the model learns to generate horses with different colors but always in the same pose - then your class probabilities will vary, but I wouldn't call this very diverse horse generation. This is how I would understand what is meant by your cited statement.
  
  The output distributions from the inception model contain class information but very little information of specific image features. Thus, the inception score cannot be sensitive to intra-class variations of the generator.
  
  > **Comments:**
  > **username_0**: "multiple horses and the model learns to generate horses with different colors but always in the same pose", yes you're right, I haven't thought of that, variance of the output's classifier would then vary but there isn't as much variability as we'd expect  
  
  ---
  
  ### Answer by username_2 on 2022-05-06. Score: 3
  
  Adding on top of username_3 answer:
  
  regarding the variance, it is unfortunately not so straight forward. The problem being that most deep learning models are not [calibrated](https://scikit-learn.org/stable/modules/calibration.html), hence small intra-class variation might lead to large probability variations for the winning class. Maybe one way to account for this issue would be to compute the [mutual information](https://en.wikipedia.org/wiki/Mutual_information) between the generated predictions and a prior expected distribution, for example uniform probability distribution 1/n with n number of expected difference within class, like horse poses to use the same example as Chillstone, but I found no reference about similar attempts, plus coming up with a proper prior expected distribution doesn't sound trivial at all. I guess the reason is that the inception score was designed for generic GANs (i.e. GANs trained to generate generic classes from CIFAR and similar dataset) so without having in mind to measure variability within classes.
  
  > **Comments:**
  > **username_3**: That's a good point - Inception is trained to be invariant to intra-class variations, so to capture this a different model or at least a differently trained inception model might be better suited. Maybe something that identifies data transformations like Capsule Net  
  > **username_0**: "small intra-class variation might lead to large probability variations for the winning class" is a weird concept to me, but I've seen this several times. Isn't the function output = f(input) continuous with regards to the input?  
  > **username_2**: not sure if I'm missing something, but the continuity of the final activation function doesn't tell you much about the properties of the function learned by a  classifier.  
  > **username_0**: @username_2 All the functions are continuous right? The last activation function is, the one to get from layer n-1 to n is too, etc.?  
  > **username_2**: sure, but again continuity doesn't imply strong constrains. The final mapping learn by a classifier is highly non linear, hence it's not surprising (even though undesired in many situations) that small changes can lad to big differences in predictions.  
  > **username_0**: Fair enough, isn't there some way to force the behaviour: small changes in the input -> small changes in the output? By integrating this into the loss or maybe by training n networks and picking the one that shows the behaviour the most out of the n networks if they all converge to similar but not same local minima?  
  > **username_2**: the problem here is how to numerically define "small change". A topic that kinda fit in this discussion but limited to CNN is [shift invariance](https://arxiv.org/abs/2011.14214), in which people try to solve the issue of CNN misclassifying images that are shifted by a few or just one pixel in one direction. That's already a way to force a model to behave constantly with respect to a predefined small change.  
  > **username_2**: another problem, a more conceptual one, is that in general we do want to learn some big changes for small input differences. It's the trade off between generalization and overfitting. So I guess that what would be required to train such a a model is actually a proper dataset. And indeed a custom loss, with an extra error component that compare for example the probability returned for a class with the expected probability we want to observe for each element belonging to that class.  
  > **username_3**: Just adding to some comments, I would think that in general, a classification model might not be the best type of model to use for intra-class variations, because its task is to be invariant to those. It always output the same result even though two horses look very different. As a general idea, maybe using a VAE model would be more suitable, as these models are build to capture as much detail as possible, right? Still experiments would have to show if this is feasible to use as a score metric like the inception model.  
  
  ---
  
  