Machine learning algorithm which gives multiple outputs from single input I need some help, i am working on a problem where i have the OCR of an image of an invoice and i want to extract certain data from it like invoice number, amount, date etc which is all present within the OCR. I tried with the classification model where i was individually passing each sentence from the OCR to the model and to predict it the invoice number or date or anything else, but this approach takes a lot of time and i don't think this is the right approach.

So, i was thinking whether there is an algorithm where i can have an input string and have outputs mapped from that string like, invoice number, date and amount are present within the string.

E.g:
Inp string: the invoice #1234 is due on 12 oct 2018 with amount of 287
Output: Invoice Number: #1234, Date: 12 oct 2018, Amount 287

So, my question is, is there an algorithm which i can train on several invoices and then make predictions?
Keras functional API's are a way your can solve you problem. Using keras functional API, we can build models that resembles more like graphs such as this: 



In order to build a model like this, you can use keras as follows:

from keras.models import Model
from keras import layers
from keras import Input

input_layer = Input(shape=(100,), dtype='float32', name="Input")
split_layer = layers.Dense(32, activation='relu', name='split_layer')(input_layer)
first_layer = layers.Dense(32, activation='relu', name='first_layer')(split_layer)
second_layer = layers.Dense(32, activation='relu', name='second_layer')(split_layer)
model = Model(input_layer,[first_layer, second_layer])
model.summary()


In order to compile this model, we can define different loss functions for different layers

model.comile(optimizer=optimizer, 
            loss={'first_layer':'mse', 'second_layer':'binary_crossentropy'},
            metrics=['accuracy'])


Once you are done with building the network, you could simply fit you data as follows:

model.fit(X,
        {'first_layer': first_layer_Y,
         'second_layer': second_layer_targets},
          epochs=10
        )