1
$\begingroup$

Consider a basic neural network like what you would expect to see in any beginner tutorial or course, and attempts to classify images as either 'cat' or 'no cat'.

I have a few questions that I've been unable to find answers for, and would be pretty time-consuming to test for answers, so hoping someone here can help instead.

  1. Does the neural network recognize some feature of 'cat-ness' from the images - say the general shape of a cat being two points ears and then a rounded face? If I trained the net entirely on images where a cat was in the left half of the photo, would it be able to recognize a cat when presented with a photo that has the cat on the right side?

  2. The activation function is based on the input value of pixels in the image, that is rgb(x, y, z), does that mean that the neural network would potentially struggle with pictures containing a black cat - since these values would be lower?

  3. My current understanding is essentially that the neural network process would be analagous to taking all of the training pictures and laying them on top of each other, and then finding the general distribution of rgb values (i.e. the pixel-wise average rgb value). Then when presented with a new image, we would take this flattened 'map' and overlay it with the new image, and see if it lines up relatively well. If yes, we determine it to be a cat image. Is this correct (for a linear activation function? at all?) How does changing the number of layers affect this analogy? What about changing the activation function?

$\endgroup$

3 Answers 3

0
$\begingroup$
  1. Does the neural network recognize some feature of 'cat-ness' from the images - say the general shape of a cat being two points ears and then a rounded face? [...]

We would hope neural networks to do that. However this does not have to be the case. Neural network learn to assign such weights to the data that give them the highest "prize" in terms of the smallest loss. Often they cheat, because don't do much about prohibiting them to cheat. Famous example was given by Ribeiro et al, of a neural network that has learned that pictures of wolves in the data had snow in background, so it can tell the picture shows a wolf if it has big white areas in it. As you can see, this has nothing to do with "wolfness" of the photo. How good, or how bad, they can get depends on many factors like the data you have, the neural network architecture, hyperparameters etc.

enter image description here

If I trained the net entirely on images where a cat was in the left half of the photo, would it be able to recognize a cat when presented with a photo that has the cat on the right side?

Theoretically, this should be solved by a convolutional neural network that has a sliding window that searches for the relevant features in different parts of the image. But again, you cannot take it for granted that it will always work, with any hyperparmeters and any data.

  1. The activation function is based on the input value of pixels in the image, that is rgb(x, y, z), does that mean that the neural network would potentially struggle with pictures containing a black cat - since these values would be lower?

If the network would somehow consider color of the cat when classifying, e.g. you trained it only on the pictures of light-coated cats, then yes, it can have problems wit black cats. Also on pictures of black cats, the details can be harder to recognize, what may make problem even harder. This can possibly happen for exactly the same reasons why human facial recognition has problems with recognizing faces of Afro-Americans.

  1. My current understanding is essentially that the neural network process would be analagous to taking all of the training pictures and laying them on top of each other, and then finding the general distribution of rgb values (i.e. the pixel-wise average rgb value). Then when presented with a new image, we would take this flattened 'map' and overlay it with the new image, and see if it lines up relatively well. If yes, we determine it to be a cat image. Is this correct (for a linear activation function? at all?) How does changing the number of layers affect this analogy? What about changing the activation function?

This is not a good analogy. First of all, neural networks have weights, so they do not treat each pixel the same. Second, neural network, on each layer, has multiple neurons, so if "stacking all pictures" could be a rough analogy (again, remember about the weights!) of logistic regression, then each layer of a neural network is multiple such regressions stacked, and you have multiple such layers learning on the results of the previous layers as features, so this gets more complicated. Moreover, activation functions, pooling layers, convolutional layers etc. make non-linear transformations to the outputs, so the "take the average" analogy is also bad because the result is not linear. There is no simple and meaningful analogy for what they do. More then this, we still do not really understand that well why do they actually work, for example, they show quite strange behavior in terms of bias-variance tradeoff (lack of it).

$\endgroup$
1
$\begingroup$

It depends what kind of neural network you are using. A convolutional neural network (CNN) with data augmentation before training should be able to handle this problem, but a multilayer perceptron (MLP), which is the kind of thing you'd see in a beginner tutorial, may not be.

  1. A CNN does seem to recognize features, starting with lower level visual features such as edges and curves and building up to more complex features like pointed ears and rounded faces. Convolution matrices are key to this feature recognition, but you wouldn't see this in a MLP. Regarding the problem of recognizing cats in the right half of the picture when training on pictures in the left half, it's common to use data augmentation to generate variations of pictures, so that wouldn't be a problem. If you have enough cat pictures, I suspect it may work even without data augmentation.

  2. In any kind of neural network, weights can be trained to handle lower intensity signals. Where this may become a problem is if the cat is black and the photo is terribly underexposed: if you can't see the cat, neither can the neural net.

  3. The problem with this understanding is that the distribution of pixels that the neural net learns is not pixel-wise, in the sense that pixels are not independent. It's a joint distribution of all the pixels in the photo, because a pixel's value is only meaningful when looked at in the context of nearby pixels. This is where the convolution matrices in a CNN come in: higher-level features of an image depend on the combination of adjacent pixels, or adjacent lower-level features. Adding more layers to a CNN would allow you to build ever more complex visual features.

$\endgroup$
0
$\begingroup$
  1. Translational and rotational invariance depends on your... everything. Feedforward, convolutional, graph, CapsNets, various activation types, objective functions and other tricks on top, the way the layers you chose above are wired...

    Starting from CNNs, they can learn features independent of their location, but that doesn't prove they always will.

  2. A major trick behind NN layers is that they can amplify or attenuate their inputs in a 'smart' way (e.g. an edge detection model amplifies the pixels IF they are on an edge ELSE it's attentuated).

    If there's even the slightest amount of contrast between the background pixels and the cat pixels, it is learnable at least in principle - your first layer could signal boost vaguely cat-shaped objects and pass them onto further layers to determine which of these are actual cats.

  3. Nnnot really, but I struggle to find a metaphor that is both correct, intuitively understandable, and isn't circular. The closest would be a very odd election system.

$\endgroup$

Your Answer

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

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