Skip to content

Commit

Permalink
Merge pull request #32 from KOSASIH/deepsource-transform-aa7c6314
Browse files Browse the repository at this point in the history
style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf
  • Loading branch information
KOSASIH authored May 11, 2024
2 parents 0769fe9 + 9f833df commit 4e882fb
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions natural_language_processing/entity_recognition.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
import tensorflow as tf


def train_entity_recognition_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.Bidirectional(tf.keras.layers.LSTM(config['hidden_units'], return_sequences=True)),
tf.keras.layers.Dense(config['output_units'], activation=config['output_activation'])
])
model = tf.keras.Sequential(
[
tf.keras.layers.Embedding(
config["vocab_size"],
config["embedding_dim"],
input_length=config["max_sequence_length"],
),
tf.keras.layers.Bidirectional(
tf.keras.layers.LSTM(config["hidden_units"], return_sequences=True)
),
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']])
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'])
model.fit(data, labels, epochs=config["epochs"], batch_size=config["batch_size"])

return model

0 comments on commit 4e882fb

Please sign in to comment.