Sequence to Sequence Learning With Neural Networks To Perform Number Addition

Sequence to Sequence Learning With Neural Networks To Perform Number Addition

In this blog, we will generate sequence as string and train a modol to learn to add two numbers. Like input string will be "125+50" and output will be "175".

We will use Short-Term Memory (LSTM) architecture to solve general sequence to sequence problems.

The idea is to use one LSTM to read the input sequence, one timestep at a time, to obtain large fixed-dimensional vector representation, and then to use another LSTM to extract the output sequence from that vector. The second LSTM is essentially a recurrent neural network language model except that it is conditioned on the input sequence. The LSTM’s ability to successfully learn on data with long range temporal dependencies makes it a natural choice for this application due to the considerable time lag between the inputs and their corresponding outputs.

Our model reads an input sentence "ABC" and produces "WXYZ" as the output sentence. The model stops making predictions after outputting the end-of-sentence token. Note that the LSTM reads the input sentence in reverse, because doing so introduces many short term dependencies in the data that make the optimization problem much easier.

What is an Encoder/Decoder in Deep Learning?

An encoder/decoder in deep learning is a technique used mainly in text generation. This global method is called "sequence to sequence". As you have an input sequence (in french for example) and you will translate it in english, so you generate another sequence. Generally, the encoder encodes the input sequence and summarizes the information in something called the internal state vectors or context vector(in case of LSTM these are called the hidden state and cell state vectors). That is used by the decoder to generate the output sequence.

The decoder is an LSTM whose initial states are initialized to the final states of the Encoder LSTM, i.e. the context vector of the encoder’s final cell is input to the first cell of the decoder network. Using these initial states, the decoder starts generating the output sequence, and these outputs are also taken into consideration for future outputs.

Import Modules

In [1]:
from tensorflow import keras
from tensorflow.keras import layers
import numpy as np

Declare the parameters for the model and dataset

In [2]:
# Parameters for the model and dataset.
TRAINING_SIZE = 50000
#TRAINING_SIZE = 100
DIGITS = 3
REVERSE = True

Get the maximum length of digit

If we add three digit numbers then maximum length of input will be 7 (DIGITS + 1 + DIGITS). Ex. "125+950".

In [3]:
MAXLEN = DIGITS + 1 + DIGITS
MAXLEN
Out[3]:
7

Create a class step by step to generate character

Create a class called GenerateSequence

In [4]:
class GenerateSequence:
    def __init__(self):
        pass

    pass

gs = GenerateSequence()
print(gs)
<__main__.GenerateSequence object at 0x000002D7C3485FD0>

Pass characters as input in constructor

In [5]:
class GenerateSequence:
    
    def __init__(self, chars):
        self.chars = chars
        pass
    
    def __str__(self):
        s = " Characters: " + str(self.chars)
        return s
        pass
        
    pass


# All the numbers, plus sign and space for padding.
chars = "0123456789+ "
gs = GenerateSequence(chars)
print(gs)
 Characters: 0123456789+ 

Add two more members in the class char_indices and indices_char

In [6]:
class GenerateSequence:
    
    def __init__(self, chars):
        self.chars = chars
        self.char_indices = dict((c, i) for i, c in enumerate(self.chars))
        self.indices_char = dict((i, c) for i, c in enumerate(self.chars))
        pass
    
    def __str__(self):
        s = "Characters: " + str(self.chars) + \
            "\nChar Indices: " + str(self.char_indices) + \
            "\nIndices Char: " + str(self.indices_char)
        return s
        pass
        
    pass


# All the numbers, plus sign and space for padding.
chars = "0123456789+ "
gs = GenerateSequence(chars)
print(gs)
Characters: 0123456789+ 
Char Indices: {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '+': 10, ' ': 11}
Indices Char: {0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9', 10: '+', 11: ' '}

Add encode and decode methods

encode function will encode the given sentence in the one-hot encoding. And decode function will give vector or 2D array to their character output. Input parameters of decode function are vector and calc_argmax.

calc_argmax: Whether to find the character index with maximum probability, defaults to "True"

In [7]:
class GenerateSequence:
    
    def __init__(self, chars):
        self.chars = chars
        self.char_indices = dict((c, i) for i, c in enumerate(self.chars))
        self.indices_char = dict((i, c) for i, c in enumerate(self.chars))
        pass
    
    def encode(self, sentence, MAXLEN):
        x = np.zeros((MAXLEN, len(self.chars)))
        for i, s in enumerate(sentence):
            x[i, self.char_indices[s]] = 1
        return x
        pass

    def decode(self, x, calc_argmax = True):
        if calc_argmax:
            x = x.argmax(axis = -1)
        return "".join(self.indices_char[x] for x in x)
        pass

    
    def __str__(self):
        s = "Characters: " + str(self.chars) + \
            "\nChar Indices: " + str(self.char_indices) + \
            "\nIndices Char: " + str(self.indices_char)
        return s
        pass
        
    pass


# All the numbers, plus sign and space for padding.
chars = "0123456789+ "
gs = GenerateSequence(chars)
print(gs)
Characters: 0123456789+ 
Char Indices: {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '+': 10, ' ': 11}
Indices Char: {0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9', 10: '+', 11: ' '}

Generate data

In [8]:
questions = []
expected = []
existed = set()


while len(questions) < TRAINING_SIZE:
    f = lambda: int(
        "".join(
            np.random.choice(list("0123456789"))
            for i in range(np.random.randint(1, DIGITS + 1))
        )
    )
    a, b = f(), f()

    ## Skip any addition questions which is already existed. To skip any such that x+Y == Y+x, so nsorting).
    key = tuple(sorted((a, b)))
    if key in existed:
        continue
    existed.add(key)
    
    # Pad the data with spaces such that it is always MAXLEN.
    q = "{}+{}".format(a, b)
    query = q + " " * (MAXLEN - len(q))
    
    ans = str(a + b)
    # Answers can be of maximum size DIGITS + 1.
    ans += " " * (DIGITS + 1 - len(ans))
    
    if REVERSE:
        # Reverse the query, e.g., '12+345  ' becomes '  543+21'. (Note the
        # space used for padding.)
        query = query[::-1]
        
    questions.append(query)
    expected.append(ans)
    
print("Total questions:", len(questions))
Total questions: 50000
In [9]:
print(questions[:20])
[' 96+661', '   58+1', '098+277', '   95+4', ' 596+68', '  3+373', ' 56+183', '  159+9', '417+866', '   18+9', '  83+56', '   1+07', '   2+37', '  71+29', ' 323+81', '  572+8', ' 191+17', '   33+5', '   6+71', '  211+0']
In [10]:
print(expected[:20])
['235 ', '86  ', '1662', '63  ', '781 ', '376 ', '446 ', '960 ', '1382', '90  ', '103 ', '71  ', '75  ', '109 ', '341 ', '283 ', '262 ', '38  ', '23  ', '112 ']

Vectorize the data

In [11]:
x = np.zeros((len(questions), MAXLEN, len(chars)), dtype = bool)
y = np.zeros((len(questions), DIGITS + 1, len(chars)), dtype = bool)
In [12]:
x.shape
Out[12]:
(50000, 7, 12)
In [13]:
y.shape
Out[13]:
(50000, 4, 12)

Enumerate questions and expected answer

In [14]:
for i, sentence in enumerate(questions):
    x[i] = gs.encode(sentence, MAXLEN)
    pass
In [15]:
for i, sentence in enumerate(expected):
    y[i] = gs.encode(sentence, DIGITS + 1)
    pass

Shuffle x and y

In [16]:
indices = np.arange(len(y))
#print(indices)
In [17]:
np.random.shuffle(indices)
#print(indices)
In [18]:
x = x[indices]
y = y[indices]
In [19]:
x.shape
Out[19]:
(50000, 7, 12)
In [20]:
y.shape
Out[20]:
(50000, 4, 12)
In [21]:
print(x[0][0])
[False False False False False False False False False False False  True]
In [22]:
print(y[0][0])
[False False False False False False  True False False False False False]

Split data in train and test

In [23]:
from sklearn.model_selection import train_test_split
In [24]:
x_train, x_validation, y_train, y_validation = train_test_split(x,y, test_size = 0.2, random_state = 50)
In [25]:
print(x_train.shape)
print(y_train.shape)
print(x_validation.shape)
print(y_validation.shape)
(40000, 7, 12)
(40000, 4, 12)
(10000, 7, 12)
(10000, 4, 12)

Create Model

This is our training model. It leverages three key features of Keras LSTM:

The return_state contructor argument, configuring a RNN layer to return a list where the first entry is the outputs and the next entries are the internal RNN states. This is used to recover the states of the encoder.

The inital_state call argument, specifying the initial state(s) of a RNN. This is used to pass the encoder states to the decoder as initial states.

The return_sequences constructor argument, configuring a RNN to return its full sequence of outputs (instead of just the last output but all the outputs in form of (num_samples, timesteps, output_dim). This is used in the decoder. This is necessary as TimeDistributed in the below expects the first dimension to be the timesteps.
In [26]:
num_layers = 1

model = keras.Sequential()
model.add(layers.LSTM(128, input_shape=(MAXLEN, len(chars))))
model.add(layers.RepeatVector(DIGITS + 1))

# The decoder RNN can be multiple layers stacked or a single layer.
for _ in range(num_layers):
    model.add(layers.LSTM(128, return_sequences=True))

model.add(layers.Dense(len(chars), activation="softmax"))

Compile the model

In [27]:
model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"])

Model Summary

In [28]:
model.summary()
Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
lstm (LSTM)                  (None, 128)               72192     
_________________________________________________________________
repeat_vector (RepeatVector) (None, 4, 128)            0         
_________________________________________________________________
lstm_1 (LSTM)                (None, 4, 128)            131584    
_________________________________________________________________
dense (Dense)                (None, 4, 12)             1548      
=================================================================
Total params: 205,324
Trainable params: 205,324
Non-trainable params: 0
_________________________________________________________________

Train the model on each epochs and predict the validation data

In [29]:
epochs = 20
batch_size = 32
In [30]:
for epoch in range(1, epochs):
    print("\nIteration", epoch)
    model.fit(
        x_train,
        y_train,
        batch_size = batch_size,
        epochs = 1,
        validation_data=(x_validation, y_validation),
    )
    # Print 10 samples from the validation set at random so we can visualize the error
    for i in range(10):
        ind = np.random.randint(0, len(x_validation))
        x_val, y_val = x_validation[np.array([ind])], y_validation[np.array([ind])]
        
        predictions = np.argmax(model.predict(x_val), axis=-1)
        #print("predictions: ", predictions)
        
        question = gs.decode(x_val[0])
        correct = gs.decode(y_val[0])
        prediction = gs.decode(predictions[0], calc_argmax = False)
        
        print("Q: ", question[::-1] if REVERSE else question, end=" ")
        print("T: ", correct, end=" ")
        
        if correct == prediction:
            print("☑ " + prediction)
        else:
            print("☒ " + prediction)
Iteration 1
1250/1250 [==============================] - 50s 30ms/step - loss: 1.7724 - accuracy: 0.3517 - val_loss: 1.5869 - val_accuracy: 0.4028
Q:  144+24  T:  168  ☒ 449 
Q:  118+20  T:  138  ☒ 220 
Q:  863+6   T:  869  ☒ 777 
Q:  94+461  T:  555  ☒ 504 
Q:  921+63  T:  984  ☒ 1024
Q:  55+58   T:  113  ☒ 55  
Q:  861+814 T:  1675 ☒ 1276
Q:  1+363   T:  364  ☒ 134 
Q:  429+59  T:  488  ☒ 500 
Q:  829+83  T:  912  ☒ 100 

Iteration 2
1250/1250 [==============================] - 34s 27ms/step - loss: 1.4149 - accuracy: 0.4718 - val_loss: 1.2394 - val_accuracy: 0.5420 1.4149 - accuracy: 0.47
Q:  716+35  T:  751  ☒ 748 
Q:  293+3   T:  296  ☒ 299 
Q:  364+721 T:  1085 ☒ 100 
Q:  381+94  T:  475  ☒ 468 
Q:  526+80  T:  606  ☒ 611 
Q:  7+789   T:  796  ☒ 899 
Q:  59+247  T:  306  ☒ 391 
Q:  33+146  T:  179  ☒ 150 
Q:  347+0   T:  347  ☒ 448 
Q:  918+67  T:  985  ☒ 991 

Iteration 3
1250/1250 [==============================] - 35s 28ms/step - loss: 1.1092 - accuracy: 0.5880 - val_loss: 0.9830 - val_accuracy: 0.6420
Q:  457+243 T:  700  ☒ 797 
Q:  31+354  T:  385  ☒ 393 
Q:  654+306 T:  960  ☒ 907 
Q:  867+111 T:  978  ☒ 901 
Q:  53+432  T:  485  ☒ 486 
Q:  421+993 T:  1414 ☒ 1499
Q:  379+57  T:  436  ☒ 437 
Q:  9+623   T:  632  ☒ 633 
Q:  13+861  T:  874  ☒ 887 
Q:  78+413  T:  491  ☒ 496 

Iteration 4
1250/1250 [==============================] - 40s 32ms/step - loss: 0.9123 - accuracy: 0.6648 - val_loss: 0.8640 - val_accuracy: 0.6806
Q:  55+183  T:  238  ☒ 235 
Q:  683+610 T:  1293 ☒ 1290
Q:  45+17   T:  62   ☒ 59  
Q:  14+12   T:  26   ☒ 31  
Q:  77+267  T:  344  ☒ 345 
Q:  656+8   T:  664  ☒ 661 
Q:  545+63  T:  608  ☒ 605 
Q:  548+86  T:  634  ☒ 631 
Q:  68+55   T:  123  ☒ 129 
Q:  547+57  T:  604  ☒ 605 

Iteration 5
1250/1250 [==============================] - 31s 25ms/step - loss: 0.7979 - accuracy: 0.7096 - val_loss: 0.7513 - val_accuracy: 0.7287
Q:  874+39  T:  913  ☒ 912 
Q:  755+877 T:  1632 ☒ 1634
Q:  64+910  T:  974  ☑ 974 
Q:  137+605 T:  742  ☒ 749 
Q:  437+45  T:  482  ☒ 481 
Q:  152+83  T:  235  ☒ 232 
Q:  860+399 T:  1259 ☑ 1259
Q:  29+960  T:  989  ☒ 987 
Q:  773+48  T:  821  ☒ 822 
Q:  44+78   T:  122  ☒ 129 

Iteration 6
1250/1250 [==============================] - 32s 26ms/step - loss: 0.7173 - accuracy: 0.7393 - val_loss: 0.6833 - val_accuracy: 0.7494
Q:  963+4   T:  967  ☑ 967 
Q:  672+8   T:  680  ☑ 680 
Q:  223+415 T:  638  ☒ 643 
Q:  977+93  T:  1070 ☒ 1060
Q:  16+41   T:  57   ☒ 54  
Q:  119+18  T:  137  ☒ 133 
Q:  95+26   T:  121  ☒ 120 
Q:  851+859 T:  1710 ☒ 1606
Q:  9+400   T:  409  ☑ 409 
Q:  560+48  T:  608  ☒ 609 

Iteration 7
1250/1250 [==============================] - 37s 29ms/step - loss: 0.6124 - accuracy: 0.7802 - val_loss: 0.5261 - val_accuracy: 0.8133
Q:  9+836   T:  845  ☒ 846 
Q:  827+219 T:  1046 ☒ 1044
Q:  90+5    T:  95   ☒ 94  
Q:  756+189 T:  945  ☑ 945 
Q:  118+5   T:  123  ☑ 123 
Q:  20+379  T:  399  ☒ 398 
Q:  67+692  T:  759  ☒ 761 
Q:  845+93  T:  938  ☒ 948 
Q:  53+230  T:  283  ☑ 283 
Q:  21+35   T:  56   ☑ 56  

Iteration 8
1250/1250 [==============================] - 38s 30ms/step - loss: 0.3913 - accuracy: 0.8691 - val_loss: 0.2942 - val_accuracy: 0.9128
Q:  871+41  T:  912  ☑ 912 
Q:  573+1   T:  574  ☑ 574 
Q:  7+523   T:  530  ☑ 530 
Q:  83+186  T:  269  ☑ 269 
Q:  0+38    T:  38   ☒ 48  
Q:  657+87  T:  744  ☑ 744 
Q:  204+9   T:  213  ☑ 213 
Q:  6+434   T:  440  ☑ 440 
Q:  106+975 T:  1081 ☑ 1081
Q:  6+995   T:  1001 ☒ 1000

Iteration 9
1250/1250 [==============================] - 41s 33ms/step - loss: 0.2322 - accuracy: 0.9381 - val_loss: 0.2266 - val_accuracy: 0.9389
Q:  169+978 T:  1147 ☒ 1136
Q:  807+280 T:  1087 ☒ 1086
Q:  39+255  T:  294  ☑ 294 
Q:  719+1   T:  720  ☑ 720 
Q:  289+958 T:  1247 ☒ 1236
Q:  619+49  T:  668  ☒ 667 
Q:  121+96  T:  217  ☑ 217 
Q:  13+136  T:  149  ☑ 149 
Q:  154+77  T:  231  ☑ 231 
Q:  61+336  T:  397  ☑ 397 

Iteration 10
1250/1250 [==============================] - 31s 25ms/step - loss: 0.1586 - accuracy: 0.9606 - val_loss: 0.1351 - val_accuracy: 0.9679
Q:  30+796  T:  826  ☑ 826 
Q:  65+261  T:  326  ☑ 326 
Q:  97+800  T:  897  ☒ 997 
Q:  8+929   T:  937  ☑ 937 
Q:  406+70  T:  476  ☑ 476 
Q:  29+437  T:  466  ☑ 466 
Q:  0+508   T:  508  ☑ 508 
Q:  883+738 T:  1621 ☑ 1621
Q:  267+330 T:  597  ☑ 597 
Q:  64+61   T:  125  ☑ 125 

Iteration 11
1250/1250 [==============================] - 32s 26ms/step - loss: 0.1092 - accuracy: 0.9744 - val_loss: 0.1142 - val_accuracy: 0.9676
Q:  3+917   T:  920  ☑ 920 
Q:  9+538   T:  547  ☑ 547 
Q:  92+823  T:  915  ☑ 915 
Q:  550+92  T:  642  ☑ 642 
Q:  983+35  T:  1018 ☑ 1018
Q:  320+913 T:  1233 ☒ 1234
Q:  209+266 T:  475  ☒ 474 
Q:  632+17  T:  649  ☑ 649 
Q:  753+65  T:  818  ☑ 818 
Q:  772+400 T:  1172 ☑ 1172

Iteration 12
1250/1250 [==============================] - 68s 55ms/step - loss: 0.0945 - accuracy: 0.9768 - val_loss: 0.0981 - val_accuracy: 0.9708- accuracy: 0.977 - ETA: 26
Q:  490+66  T:  556  ☑ 556 
Q:  52+65   T:  117  ☑ 117 
Q:  838+65  T:  903  ☑ 903 
Q:  74+15   T:  89   ☑ 89  
Q:  53+940  T:  993  ☑ 993 
Q:  508+457 T:  965  ☑ 965 
Q:  291+25  T:  316  ☑ 316 
Q:  79+838  T:  917  ☑ 917 
Q:  991+86  T:  1077 ☑ 1077
Q:  241+4   T:  245  ☑ 245 

Iteration 13
1250/1250 [==============================] - 47s 37ms/step - loss: 0.0693 - accuracy: 0.9837 - val_loss: 0.0768 - val_accuracy: 0.9795
Q:  96+513  T:  609  ☑ 609 
Q:  120+55  T:  175  ☑ 175 
Q:  141+18  T:  159  ☑ 159 
Q:  949+14  T:  963  ☑ 963 
Q:  9+148   T:  157  ☑ 157 
Q:  753+143 T:  896  ☑ 896 
Q:  377+40  T:  417  ☑ 417 
Q:  53+428  T:  481  ☑ 481 
Q:  14+348  T:  362  ☑ 362 
Q:  421+4   T:  425  ☑ 425 

Iteration 14
1250/1250 [==============================] - 43s 34ms/step - loss: 0.0530 - accuracy: 0.9877 - val_loss: 0.0707 - val_accuracy: 0.9797s: 0.0529 - accuracy:  - ETA: 0s - loss: 0.0530 - accuracy: 0.
Q:  187+516 T:  703  ☑ 703 
Q:  578+479 T:  1057 ☒ 1067
Q:  37+31   T:  68   ☑ 68  
Q:  943+4   T:  947  ☑ 947 
Q:  174+19  T:  193  ☒ 293 
Q:  11+883  T:  894  ☑ 894 
Q:  75+957  T:  1032 ☑ 1032
Q:  185+3   T:  188  ☑ 188 
Q:  442+72  T:  514  ☑ 514 
Q:  40+165  T:  205  ☑ 205 

Iteration 15
1250/1250 [==============================] - 32s 25ms/step - loss: 0.0493 - accuracy: 0.9884 - val_loss: 0.0483 - val_accuracy: 0.9868
Q:  288+8   T:  296  ☑ 296 
Q:  9+503   T:  512  ☑ 512 
Q:  73+793  T:  866  ☑ 866 
Q:  811+50  T:  861  ☑ 861 
Q:  2+332   T:  334  ☑ 334 
Q:  746+91  T:  837  ☑ 837 
Q:  481+853 T:  1334 ☑ 1334
Q:  58+970  T:  1028 ☑ 1028
Q:  683+610 T:  1293 ☒ 1393
Q:  33+146  T:  179  ☑ 179 

Iteration 16
1250/1250 [==============================] - 45s 36ms/step - loss: 0.0477 - accuracy: 0.9874 - val_loss: 0.0445 - val_accuracy: 0.9875
Q:  536+28  T:  564  ☑ 564 
Q:  8+344   T:  352  ☑ 352 
Q:  5+97    T:  102  ☑ 102 
Q:  374+78  T:  452  ☑ 452 
Q:  430+47  T:  477  ☑ 477 
Q:  202+40  T:  242  ☑ 242 
Q:  97+947  T:  1044 ☑ 1044
Q:  40+2    T:  42   ☑ 42  
Q:  848+993 T:  1841 ☒ 1831
Q:  17+849  T:  866  ☑ 866 

Iteration 17
1250/1250 [==============================] - 44s 35ms/step - loss: 0.0502 - accuracy: 0.9867 - val_loss: 0.1173 - val_accuracy: 0.9595
Q:  60+734  T:  794  ☑ 794 
Q:  39+492  T:  531  ☑ 531 
Q:  973+532 T:  1505 ☑ 1505
Q:  604+459 T:  1063 ☑ 1063
Q:  816+138 T:  954  ☑ 954 
Q:  4+245   T:  249  ☑ 249 
Q:  270+6   T:  276  ☑ 276 
Q:  95+4    T:  99   ☑ 99  
Q:  5+547   T:  552  ☑ 552 
Q:  699+61  T:  760  ☑ 760 

Iteration 18
1250/1250 [==============================] - 51s 41ms/step - loss: 0.0424 - accuracy: 0.9881 - val_loss: 0.0465 - val_accuracy: 0.9861
Q:  44+931  T:  975  ☑ 975 
Q:  77+706  T:  783  ☑ 783 
Q:  10+33   T:  43   ☑ 43  
Q:  18+886  T:  904  ☑ 904 
Q:  20+26   T:  46   ☑ 46  
Q:  277+4   T:  281  ☑ 281 
Q:  272+44  T:  316  ☑ 316 
Q:  321+59  T:  380  ☑ 380 
Q:  602+4   T:  606  ☑ 606 
Q:  551+39  T:  590  ☑ 590 

Iteration 19
1250/1250 [==============================] - 46s 37ms/step - loss: 0.0368 - accuracy: 0.9904 - val_loss: 0.1513 - val_accuracy: 0.9435
Q:  48+993  T:  1041 ☑ 1041
Q:  65+182  T:  247  ☑ 247 
Q:  329+168 T:  497  ☑ 497 
Q:  166+72  T:  238  ☑ 238 
Q:  89+458  T:  547  ☑ 547 
Q:  96+76   T:  172  ☑ 172 
Q:  352+71  T:  423  ☑ 423 
Q:  15+540  T:  555  ☑ 555 
Q:  42+846  T:  888  ☑ 888 
Q:  8+348   T:  356  ☑ 356 

Now we have got the 99% validation accuracy.

In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 

Machine Learning

  1. Deal Banking Marketing Campaign Dataset With Machine Learning

TensorFlow

  1. Difference Between Scalar, Vector, Matrix and Tensor
  2. TensorFlow Deep Learning Model With IRIS Dataset
  3. Sequence to Sequence Learning With Neural Networks To Perform Number Addition
  4. Image Classification Model MobileNet V2 from TensorFlow Hub
  5. Step by Step Intent Recognition With BERT
  6. Sentiment Analysis for Hotel Reviews With NLTK and Keras
  7. Simple Sequence Prediction With LSTM
  8. Image Classification With ResNet50 Model
  9. Predict Amazon Inc Stock Price with Machine Learning
  10. Predict Diabetes With Machine Learning Algorithms
  11. TensorFlow Build Custom Convolutional Neural Network With MNIST Dataset
  12. Deal Banking Marketing Campaign Dataset With Machine Learning

PySpark

  1. How to Parallelize and Distribute Collection in PySpark
  2. Role of StringIndexer and Pipelines in PySpark ML Feature - Part 1
  3. Role of OneHotEncoder and Pipelines in PySpark ML Feature - Part 2
  4. Feature Transformer VectorAssembler in PySpark ML Feature - Part 3
  5. Logistic Regression in PySpark (ML Feature) with Breast Cancer Data Set

PyTorch

  1. Build the Neural Network with PyTorch
  2. Image Classification with PyTorch
  3. Twitter Sentiment Classification In PyTorch
  4. Training an Image Classifier in Pytorch

Natural Language Processing

  1. Spelling Correction Of The Text Data In Natural Language Processing
  2. Handling Text For Machine Learning
  3. Extracting Text From PDF File in Python Using PyPDF2
  4. How to Collect Data Using Twitter API V2 For Natural Language Processing
  5. Converting Text to Features in Natural Language Processing
  6. Extract A Noun Phrase For A Sentence In Natural Language Processing