'For pytorch RNN model, can we inference the input by its output results?

all,

I wonder, torch.nn.rnn(~). If I know the final output, does it possible, I could inference its input value? For example:

myrnn = nn.RNN(4, 2, 1, batch_first=True)
expected_out, hidden = myrnn(input)
expected_out:  tensor([[[-0.7773, -0.2031]],

    [[-0.4129, -0.1802]],

    [[ 0.0599, -0.0151]],

    [[-0.9273,  0.2683]],

    [[ 0.6161,  0.5412]]])

Thank you so mcuh!!!



Solution 1:[1]

What you are asking is theoretically impossible

Neural networks in general represent functions that are impossible to inverse as they are not guaranteed to be byjective regardless of the underlying architecture.

This means that neither rnn nor any other neural network are invertible.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Paul_0