Created
August 30, 2024 06:25
-
-
Save saimadhu-polamuri/1847e7d63eb75d2cf6df760597039764 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Tokenize text and create word-to-index mapping | |
| tokenizer = tf.keras.preprocessing.text.Tokenizer() | |
| tokenizer.fit_on_texts(data["preprocessed_text"]) | |
| sequences = tokenizer.texts_to_sequences(data["preprocessed_text"]) | |
| padded_sequences = tf.keras.preprocessing.sequence.pad_sequences(sequences, maxlen=max_length) | |
| # Create training data | |
| X_train, X_val, y_train, y_val = train_test_split(padded_sequences, padded_sequences, test_size=0.2, random_state=42) | |
| # Train the model | |
| history = model.fit(X_train, y_train, epochs=10, batch_size=32, validation_data=(X_val, y_val)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment