A computer-implemented method for training a neural network with a graph-based temporal classification, GTC, objective function using supervisory information from a directed graph of nodes connected by edges representing labels and transitions among the labels, wherein the labels correspond to words, sub-words, and/or characters from an alphabet of a particular language, wherein the directed graph represents possible alignment paths for a sequence of probability distributions outputted by a neural network and the labels, wherein a structure of the directed graph specifies one or a combination of a non-monotonic alignment between a sequence of labels and the sequence of probability distributions and a constraint on label repetitions in the sequence of labels, wherein an input to the neural network is a sequence of observations comprising features extracted from a speech utterance and an output of the neural network is the sequence of probability distributions over all labels in a set of labels, comprising: receiving a training set comprising data indicative of sequences of observations and corresponding sequences of labels; executing the neural network to transform the sequence of observations into the sequence of probability distributions; and updating parameters of the neural network based on the GTC objective function configured to maximize a sum of conditional probabilities of all possible sequences of labels that are generated by unfolding the directed graph to the length of the sequence of probability distributions and mapping each unfolded sequence of nodes and edges to a sequence of labels, wherein the sum of the conditional probabilities of all sequences of labels is estimated from the sequence of probability distributions determined by the neural network; wherein the directed graph represents multiple possible alignment paths for the sequence of probability distributions and the sequence of labels such that possible passes through the structure of the directed graph allows multiple unique label sequences, which are obtained after collapsing label repetitions and removing blank labels from the multiple unique label sequences, thereby resulting in the non-monotonic alignment between the sequence of labels and the sequence of probability distributions; wherein the constraint on label repetitions specified by the structure of the directed graph is achieved by removing a self-transition to a node representing a label and adding to the node a transition to other nodes representing the same label; and wherein the unfolding of the directed graph comprises generating different sequences of labels and alignment paths according to the structure of the directed graph such that the length of each of the generated sequence of labels matches the length of the sequence of probability distributions. receiving a training set comprising data indicative of sequences of observations and corresponding sequences of labels; executing the neural network to transform the sequence of observations into the sequence of probability distributions; and updating parameters of the neural network based on the GTC objective function configured to maximize a sum of conditional probabilities of all possible sequences of labels that are generated by unfolding the directed graph to the length of the sequence of probability distributions and mapping each unfolded sequence of nodes and edges to a sequence of labels, wherein the sum of the conditional probabilities of all sequences of labels is estimated from the sequence of probability distributions determined by the neural network; wherein the directed graph represents multiple possible alignment paths for the sequence of probability distributions and the sequence of labels such that possible passes through the structure of the directed graph allows multiple unique label sequences, which are obtained after collapsing label repetitions and removing blank labels from the multiple unique label sequences, thereby resulting in the non-monotonic alignment between the sequence of labels and the sequence of probability distributions; wherein the constraint on label repetitions specified by the structure of the directed graph is achieved by removing a self-transition to a node representing a label and adding to the node a transition to other nodes representing the same label; and wherein the unfolding of the directed graph comprises generating different sequences of labels and alignment paths according to the structure of the directed graph such that the length of each of the generated sequence of labels matches the length of the sequence of probability distributions.