Created
July 19, 2020 09:54
-
-
Save saimadhu-polamuri/fed7eb153c0c4b3994312840118aabfb to your computer and use it in GitHub Desktop.
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
def train_model(model, train_data, optimizer, batch_size, epochs=10): | |
losses = {} | |
random.seed(1) | |
for epoch in range(epochs): | |
random.shuffle(train_data) | |
batches = minibatch(train_data, size=batch_size) | |
for batch in batches: | |
# Split batch into texts and labels | |
texts, labels = zip(*batch) | |
# Update model with texts and labels | |
model.update(texts, labels, sgd=optimizer, losses=losses) | |
print("Loss: {}".format(losses['textcat'])) | |
return losses['textcat'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment