Assume that I have a fully connected network that takes in a vector containing 1025 elements. First 1024 elements are related to the input image of size 32 x 32 x 1, and the last element in the vector (1025-th element) is a control bit that I call it special input.

When this bit is zero, the network should predict if there is a cat in the image or not, and when this bit is one, it should predict if there is a dog in the image or not.

So how can I tell the network that your 1025-th element should be special to you and you should pay more attention to it?

Note that it's just an example and the real problem is more complex than this. So please don't bypass the goal of this question by using tricks special to this example. Any idea is appreciated.

  • 1
    $\begingroup$ The main benefit of deep learning is that you don't have to manually design your features. The network itself will map it. So, I suppose you can just train your algorithm with your dataset. $\endgroup$ Oct 21, 2020 at 14:28
  • $\begingroup$ Thank you for commenting. My hope of this happening was so low that I did not even bother myself to test a simple scenario like this. But as you say it will happen, I will test it soon and return the result here. $\endgroup$
    – amin
    Oct 21, 2020 at 14:46
  • $\begingroup$ @ArayKarjauv Yes it worked. If you want, you can write your comment as answer and I will accept it $\endgroup$
    – amin
    Oct 21, 2020 at 15:58
  • $\begingroup$ by the way, you can also add one more input layer for your flag. I updated my answer. $\endgroup$ Oct 21, 2020 at 16:53

2 Answers 2


The main benefit of deep learning is that you don't have to manually design features.

Classic Machine Learning algorithms always include the Feature engineering step, whereas neural networks are able to extract features automatically during learning. The classic example is CNN. In the first layer, it creates simple features that representing lines, the last layers represent abstract features. Of course, some tasks do require feature engineering (e.g. signal processing).

In your case, if you want to take advantage of the CNN network, you can also add an additional input layer for the flag (e.g. as one-hot vector). Here is an illustration taken from this answer.

enter image description here

  • $\begingroup$ Your comments and answer seems a few contradictory. First you propose handle in same way all 1025 inputs, next you talk about a CNN (with 32*32+1 inputs ?) and finally propose an architecture with two separated stages. $\endgroup$ Oct 21, 2020 at 18:06
  • $\begingroup$ there are different approaches. I assume, the authors feeds an image as a NxM vector, as he mentioned that he has 1025-th element. So it is possible to add one extra feature. I have also added some additional information on CCN for generalization $\endgroup$ Oct 21, 2020 at 18:14
  • $\begingroup$ Are neural nets in general able to crate features automatically during learning, or this is a specific characteristic of CNNs? $\endgroup$
    – desertnaut
    Oct 21, 2020 at 21:28
  • $\begingroup$ This applies not only to CNN. As I wrote, CNN is just a classic example. $\endgroup$ Oct 21, 2020 at 22:17

Assume the image can contain objects of class $C_1 \dots C_c$. Assume a set of additional inputs that has a meaning of questions as "contains the image a C_i or C_j or ... ?".

The main problem for the system is classify the image in classes $C_i$. Second problem is answer the implicit question proposed by the remainder inputs.

Thus, better combine two NNs:

  • first one an object recognizer, with input the image data.
  • second one a NN that will answer the question implicit in remainder bits, with inputs the output of previous NN and the "question" bits.

In concrete for the example that the question describe:

  • a NN to classify dog/cat from 32x32 image. Two outputs for probabilities of dog an cat. Or simply one binary output 0:"is a dog", 1:"is a cat".
  • a second NN with the "1025" binary input ( 0: "look for dogs", 1: "look for cats") and output from previous one. In this case, if everything is ok, it will infer the logic "a==b": "is a dog" and "look for dogs" or "is a cat" and "look for cats".

Note that if you try to solve the problem directly with a full-connected NN with all inputs (1025 in the example), you loss the possibility of use CNN and max-pooling layers, etc. Moreover, split decreases training times, join subjects increases them "exponentially". Not a promising way.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .