From 13c169142662ec9c3f6040f8374e1d05f8aa71cf Mon Sep 17 00:00:00 2001 From: joe Date: Wed, 30 Jan 2019 10:39:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=AA=8C=E8=AF=81=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- data/{test.csv => dev.csv} | 0 similarity.py | 20 ++++++++++---------- 3 files changed, 11 insertions(+), 11 deletions(-) rename data/{test.csv => dev.csv} (100%) diff --git a/README.md b/README.md index ca1ceef..e95fad6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # bert-utils -本文基于Google开源的[BERT]()代码进行了进一步的简化,方便生成句向量与做文本分类 +本文基于Google开源的[BERT](https://github.com/google-research/bert)代码进行了进一步的简化,方便生成句向量与做文本分类 1、下载BERT中文模型 diff --git a/data/test.csv b/data/dev.csv similarity index 100% rename from data/test.csv rename to data/dev.csv diff --git a/similarity.py b/similarity.py index 4d6e792..0472070 100644 --- a/similarity.py +++ b/similarity.py @@ -664,13 +664,13 @@ class BertSim: if __name__ == '__main__': sim = BertSim() - # sim.set_mode(tf.estimator.ModeKeys.TRAIN) - # sim.train() - # sim.set_mode(tf.estimator.ModeKeys.EVAL) - # sim.eval() - sim.set_mode(tf.estimator.ModeKeys.PREDICT) - while True: - sentence1 = input('sentence1: ') - sentence2 = input('sentence2: ') - predict = sim.predict(sentence1, sentence2) - print(f'similarity:{predict[0][1]}') + sim.set_mode(tf.estimator.ModeKeys.TRAIN) + sim.train() + sim.set_mode(tf.estimator.ModeKeys.EVAL) + sim.eval() + # sim.set_mode(tf.estimator.ModeKeys.PREDICT) + # while True: + # sentence1 = input('sentence1: ') + # sentence2 = input('sentence2: ') + # predict = sim.predict(sentence1, sentence2) + # print(f'similarity:{predict[0][1]}')