Loss function for an RNN used for binary classification
The second option is the good one.


You can select the last output that correspond to a not padded input and using it for your loss.
Or you can directly express that explicitly : in keras set the flag return_sequence to False and your RNN layer will only give you the last output that correspond to a not padded input.


If I were you I would try to put a dense layer between the RNN layer and the last output. Don't forget to use a softmax activation function for the last layer in order to get probabilities.