Model Pipeline - RNN for text classification
This pipeline uses a Recurrent Neural Network (RNN) to read sentences word by word and decide what category the sentence belongs to, like sorting emails into spam or not spam.
Jump into concepts and practice - no test required
This pipeline uses a Recurrent Neural Network (RNN) to read sentences word by word and decide what category the sentence belongs to, like sorting emails into spam or not spam.
Loss
0.7 |****
0.6 |***
0.5 |**
0.4 |*
0.3 |
1 2 3 4 5 Epochs| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.65 | 0.60 | Model starts learning, accuracy is low but improving |
| 2 | 0.48 | 0.75 | Loss decreases, accuracy improves significantly |
| 3 | 0.38 | 0.82 | Model is learning important patterns |
| 4 | 0.32 | 0.86 | Loss continues to decrease, accuracy rises |
| 5 | 0.28 | 0.89 | Model converges with good accuracy |
model = Sequential() model.add(Embedding(input_dim=5000, output_dim=16, input_length=10)) model.add(SimpleRNN(8)) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) history = model.fit(X_train, y_train, epochs=2, batch_size=32) print(history.history['accuracy'][-1])
history.history['accuracy'][-1] represent?model = Sequential() model.add(SimpleRNN(16)) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
Original: model = Sequential() model.add(SimpleRNN(16, input_shape=(10, 100))) model.add(Dense(1, activation='sigmoid')) Change: model = Sequential() model.add(Embedding(input_dim=5000, output_dim=100, input_length=10)) model.add(SimpleRNN(16)) model.add(Dense(1, activation='sigmoid'))