-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from KOSASIH/deepsource-transform-aa7c6314
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
Showing
1 changed file
with
20 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
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 |