Skip to content

Commit

Permalink
Create sentiment_analysis.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored May 11, 2024
1 parent 28f72dc commit 0245df4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions natural_language_processing/sentiment_analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import tensorflow as tf

def train_sentiment_analysis_model(data, labels, config):
# Define the model architecture
model = tf.keras.Sequential([
tf.keras.layers.Embedding(config['vocab_size'], config['embedding_dim'], input_length=config['max_sequence_length']),
tf.keras.layers.GlobalAveragePooling1D(),
tf.keras.layers.Dense(config['output_units'], activation=config['output_activation'])
])

# Compile the model
model.compile(optimizer=config['optimizer'],
loss=config['loss'],
metrics=[config['metric']])

# Train the model
model.fit(data, labels, epochs=config['epochs'], batch_size=config['batch_size'])

return model

0 comments on commit 0245df4

Please sign in to comment.