Answers.Body: <p>You're describing unsupervised learning.  Neural networks require a loss function and if you don’t know what you’re learning that can be tough.</p>
  <p>That’s not to say this isn’t possible, autoencoders performs something resembling unsupervised learning by optimizing a different goal.  I googled “autoencoder cats versus dogs” and some git projects came up.</p>
  <p>As a final note, neural networks have a fixed set of parameters, a number of classes to identify must be chosen at engineering time.  Figuring out how many classes exist in an unlabeled dataset is its own hard problem.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-08-24T13:42:39.940Z
Answers.LastActivityDate: 2024-08-24T13:42:39.940Z
Answers.UserDisplayName: foreverska
Answers.Body: <p>To see the difficulty of this, let’s look at two dog pictures and two cat pictures.</p>
  <p><a href="https://s3.amazonaws.com/cdn-origin-etr.akc.org/wp-content/uploads/2019/11/13133916/American-Staffordshire-Terrier-laying-down-with-a-ball-outdoors-in-the-grass.20190811203127332.jpg" rel="nofollow noreferrer"><img src="https://s3.amazonaws.com/cdn-origin-etr.akc.org/wp-content/uploads/2019/11/13133916/American-Staffordshire-Terrier-laying-down-with-a-ball-outdoors-in-the-grass.20190811203127332.jpg" alt="dog outside" /></a>
  <a href="https://www.shutterstock.com/image-photo/domestic-animal-closeup-portrait-cute-600nw-1953680527.jpg" rel="nofollow noreferrer"><img src="https://www.shutterstock.com/image-photo/domestic-animal-closeup-portrait-cute-600nw-1953680527.jpg" alt="dog inside" /></a>
  <a href="https://www.armandhammer.com/-/media/aah/feature/articles/cat-litter-articles/headercatimg.jpg" rel="nofollow noreferrer"><img src="https://www.armandhammer.com/-/media/aah/feature/articles/cat-litter-articles/headercatimg.jpg" alt="cat outside" /></a>
  <a href="https://www.zooplus.co.uk/magazine/wp-content/uploads/2021/07/Indoor-Cat.jpeg" rel="nofollow noreferrer"><img src="https://www.zooplus.co.uk/magazine/wp-content/uploads/2021/07/Indoor-Cat.jpeg" alt="cat inside" /></a></p>
  <p>Your machine learning model might pick up on the fact that the first two are dogs and second two are cats. It, instead , might pick up on which animals are inside and which are outside, and such labels are totally reasonable to assign. You would then be training your model to detect if the animal is inside or outside, rather than distinguishing between the animals.</p>
  <p>This relates to what I discuss in the final two plots of my answer <a href="https://stats.stackexchange.com/a/625461/247274">here</a>.</p>
  <p>On the topic of being able to say that the picture is neither a dog nor a cat, I see two options.</p>
  <ol>
  <li><p>A typical binary problem where the image is assigned as neither if neither category has a particularly high probability, dividing the prediction space into three ranges instead of two. For instance, when you call the <code>predict_proba</code> method from <code>Scitkit-learn</code>, you get an output like <code>[0.45, 0.55]</code>. A traditional (even if often problamatic) decision rule would assign a categorical prediction of the second category. Since there is only a <span class="math-container">$55\%$</span> chance of that being true, perhaps that would be a time to say the image is neither a dog nor a cat.</p>
  </li>
  <li><p>A multi-label approach where the probabilities of each animal can come back low. If the predicted probabilities of both animals are low, maybe the image contains something other than a dog or a cat. The differs from the above, because the above requires the two probabilities to sum to one. The multi-label has no such requirement, so you can wind up with predictions like <code>[0.02, 0.03]</code>, where the second category is slightly more likely to be in the image, but odds are against either animal being in the image.</p>
  </li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-08-26T08:02:25.390Z
Answers.LastActivityDate: 2024-08-26T08:02:25.390Z
Answers.UserDisplayName: Dave
Body: <p>I would like to have a neural network that is able to automatically discover classes.</p>
  <p>For example, I give to the untrained network pictures both of cats and dogs, and it will automatically assign them to 2 distinct classes. Without the need to tell the network if it is a cat or a dog.</p>
  <p>After training, during inference, when I give a picture to the network, it will be able to recognize 3 classes giving a probability for each of them:</p>
  <ul>
  <li>Cat</li>
  <li>Dog</li>
  <li>Other</li>
  </ul>
  <p>And with the fact that I don't know how many classes there are, the network should create a new class when needed.</p>
  <p>So I wonder if a such neural network has already been engineered by some AI specialists ?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-08-24T15:03:21.157Z
Comments.Text: There are some very difficult and unsolved problems in your simple view of the question. For example why would an automated system decide to classify by animal type, especially with such diverse animals as cats and dogs? It could just as easily to decide to classify by indoor vs outdoor picture, fur colour of the creature, night vs daytime picture, what action is being performed etc. How would it know your goal is to identify creature type (i.e. how could you tell it this in general, without labelling the training data)?
Comments.UserDisplayName: Neil Slater
Tags: <neural-networks><classification>
Title: Make a neural network automatically discover classes?
UserDisplayName: Bertrand125
ThreadText: # Make a neural network automatically discover classes?
  
  (Asked by: username_0 on 2024-08-24)
  
  I would like to have a neural network that is able to automatically discover classes.
  
  For example, I give to the untrained network pictures both of cats and dogs, and it will automatically assign them to 2 distinct classes. Without the need to tell the network if it is a cat or a dog.
  
  After training, during inference, when I give a picture to the network, it will be able to recognize 3 classes giving a probability for each of them:
  
  * Cat
  * Dog
  * Other
  
  And with the fact that I don't know how many classes there are, the network should create a new class when needed.
  
  So I wonder if a such neural network has already been engineered by some AI specialists ?
  
  **Tags:** neural-networks, classification
  > **Comments:**
  > **username_1**: There are some very difficult and unsolved problems in your simple view of the question. For example why would an automated system decide to classify by animal type, especially with such diverse animals as cats and dogs? It could just as easily to decide to classify by indoor vs outdoor picture, fur colour of the creature, night vs daytime picture, what action is being performed etc. How would it know your goal is to identify creature type (i.e. how could you tell it this in general, without labelling the training data)?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2024-08-24. Score: 2 | Accepted answer
  
  You're describing unsupervised learning. Neural networks require a loss function and if you don’t know what you’re learning that can be tough.
  
  That’s not to say this isn’t possible, autoencoders performs something resembling unsupervised learning by optimizing a different goal. I googled “autoencoder cats versus dogs” and some git projects came up.
  
  As a final note, neural networks have a fixed set of parameters, a number of classes to identify must be chosen at engineering time. Figuring out how many classes exist in an unlabeled dataset is its own hard problem.
  
  
  ---
  
  ### Answer by username_3 on 2024-08-26. Score: 2
  
  To see the difficulty of this, let’s look at two dog pictures and two cat pictures.
  
  [![dog outside](https://s3.amazonaws.com/cdn-origin-etr.akc.org/wp-content/uploads/2019/11/13133916/American-Staffordshire-Terrier-laying-down-with-a-ball-outdoors-in-the-grass.20190811203127332.jpg)](https://s3.amazonaws.com/cdn-origin-etr.akc.org/wp-content/uploads/2019/11/13133916/American-Staffordshire-Terrier-laying-down-with-a-ball-outdoors-in-the-grass.20190811203127332.jpg)
  [![dog inside](https://www.shutterstock.com/image-photo/domestic-animal-closeup-portrait-cute-600nw-1953680527.jpg)](https://www.shutterstock.com/image-photo/domestic-animal-closeup-portrait-cute-600nw-1953680527.jpg)
  [![cat outside](https://www.armandhammer.com/-/media/aah/feature/articles/cat-litter-articles/headercatimg.jpg)](https://www.armandhammer.com/-/media/aah/feature/articles/cat-litter-articles/headercatimg.jpg)
  [![cat inside](https://www.zooplus.co.uk/magazine/wp-content/uploads/2021/07/Indoor-Cat.jpeg)](https://www.zooplus.co.uk/magazine/wp-content/uploads/2021/07/Indoor-Cat.jpeg)
  
  Your machine learning model might pick up on the fact that the first two are dogs and second two are cats. It, instead , might pick up on which animals are inside and which are outside, and such labels are totally reasonable to assign. You would then be training your model to detect if the animal is inside or outside, rather than distinguishing between the animals.
  
  This relates to what I discuss in the final two plots of my answer [here](https://stats.stackexchange.com/a/625461/247274).
  
  On the topic of being able to say that the picture is neither a dog nor a cat, I see two options.
  
  1. A typical binary problem where the image is assigned as neither if neither category has a particularly high probability, dividing the prediction space into three ranges instead of two. For instance, when you call the `predict_proba` method from `Scitkit-learn`, you get an output like `[0.45, 0.55]`. A traditional (even if often problamatic) decision rule would assign a categorical prediction of the second category. Since there is only a $55\%$ chance of that being true, perhaps that would be a time to say the image is neither a dog nor a cat.
  2. A multi-label approach where the probabilities of each animal can come back low. If the predicted probabilities of both animals are low, maybe the image contains something other than a dog or a cat. The differs from the above, because the above requires the two probabilities to sum to one. The multi-label has no such requirement, so you can wind up with predictions like `[0.02, 0.03]`, where the second category is slightly more likely to be in the image, but odds are against either animal being in the image.
  
  
  ---
  
  