def train_and_eval(embeddings_name, fold_count, use_ELMo=False): batch_size = 256 if use_ELMo: batch_size = 20 model = Classifier('citations', "gru", list_classes=list_classes, max_epoch=70, fold_number=fold_count, use_roc_auc=True, embeddings_name=embeddings_name, use_ELMo=use_ELMo, batch_size=batch_size, class_weights=class_weights) print('loading citation sentiment corpus...') xtr, y = load_citation_sentiment_corpus( "data/textClassification/citations/citation_sentiment_corpus.txt") # segment train and eval sets x_train, y_train, x_test, y_test = split_data_and_labels(xtr, y, 0.9) if fold_count == 1: model.train(x_train, y_train) else: model.train_nfold(x_train, y_train) model.eval(x_test, y_test) # saving the model model.save()
def train(embeddings_name, fold_count, use_ELMo=False): batch_size = 256 if use_ELMo: batch_size = 20 model = Classifier('citations', "gru", list_classes=list_classes, max_epoch=70, fold_number=fold_count, use_roc_auc=True, embeddings_name=embeddings_name, use_ELMo=use_ELMo, batch_size=batch_size, class_weights=class_weights) print('loading citation sentiment corpus...') xtr, y = load_citation_sentiment_corpus( "data/textClassification/citations/citation_sentiment_corpus.txt") if fold_count == 1: model.train(xtr, y) else: model.train_nfold(xtr, y) # saving the model model.save()
def train(embeddings_name, fold_count, use_ELMo=False, use_BERT=False, architecture="gru"): batch_size, maxlen = configure(architecture, use_BERT, use_ELMo) model = Classifier('citations', model_type=architecture, list_classes=list_classes, max_epoch=100, fold_number=fold_count, patience=10, use_roc_auc=True, embeddings_name=embeddings_name, use_ELMo=use_ELMo, use_BERT=use_BERT, batch_size=batch_size, maxlen=maxlen, class_weights=class_weights) print('loading citation sentiment corpus...') xtr, y = load_citation_sentiment_corpus( "data/textClassification/citations/citation_sentiment_corpus.txt") if fold_count == 1: model.train(xtr, y) else: model.train_nfold(xtr, y) # saving the model model.save()
def train(embeddings_name, fold_count, architecture="gru", transformer=None): batch_size, maxlen, patience, early_stop, max_epoch = configure( architecture) model = Classifier('citations_' + architecture, architecture=architecture, list_classes=list_classes, max_epoch=max_epoch, fold_number=fold_count, use_roc_auc=True, embeddings_name=embeddings_name, batch_size=batch_size, maxlen=maxlen, patience=patience, early_stop=early_stop, class_weights=class_weights, transformer_name=transformer) print('loading citation sentiment corpus...') xtr, y = load_citation_sentiment_corpus( "data/textClassification/citations/citation_sentiment_corpus.txt") if fold_count == 1: model.train(xtr, y) else: model.train_nfold(xtr, y) # saving the model model.save()
def train(embeddings_name, fold_count): model = Classifier('citations', "gru", list_classes=list_classes, max_epoch=70, fold_number=fold_count, use_roc_auc=True, embeddings_name=embeddings_name) print('loading citation sentiment corpus...') xtr, y = load_citation_sentiment_corpus( "data/textClassification/citations/citation_sentiment_corpus.txt") if fold_count == 1: model.train(xtr, y) else: model.train_nfold(xtr, y) # saving the model model.save()