I have a fully-connected neural network whose input is a vector of $n$ (normalized) integers. Each of these integers is associated with an object. The output is similarly a vector of $n$ values each of which is the prediction of a metric corresponding to one of those objects. The network is trained using the data of all $n$ objects.

Now, I need to consider the prediction scenario above in a faulty manner, say, a fault just eliminates one of those objects. Now, I am wondering whether or not I can use the very neural network above to predict the features of the remaining $n-1$ objects. In particular, I don't who what I need to feed into the input associated with the eliminated object.

Any thoughts and ideas are welcome!


1 Answer 1


You could have an additional $n$ binary inputs which indicates whether each object is present or not.

Alternatively, you could have an architecture which can take in a variable number of inputs and produce a variable number of outputs. For example, given inputs $x_i$, embed them to $z_i = f(x_i)$, then let $z = \sum_i z_i$, and have output $y_i = g(x_i, z)$, where $f$ and $g$ are both neural networks. This scheme doesn't rely on there being any fixed number of objects.

  • $\begingroup$ Can you explain how the second approach can be implemented, e.g., in keras? $\endgroup$
    – user320667
    Commented Nov 13, 2021 at 17:12
  • $\begingroup$ $f$ and $g$ can just be keras layers or modules (or whatever the name for it is, i'm not super familiar with keras). Then you can define your keras model which invokes $f$ and $g$ and carries out the computation. $\endgroup$
    – shimao
    Commented Nov 13, 2021 at 17:20
  • $\begingroup$ The point is that one can train a network based on a fixed architecture, right? If so, how does the network adapt iteself to the variation of inputs and outputs? If you know any example, I shall be grateful if you put its link here. $\endgroup$
    – user320667
    Commented Nov 13, 2021 at 17:35
  • $\begingroup$ i'm not sure i follow the question - there's no requirement that neural networks have a "fixed" architecture. all you need is the ability to compute the gradient of the loss wrt the parameters, which is possible in this setup $\endgroup$
    – shimao
    Commented Nov 14, 2021 at 17:23

Your Answer

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