示例#1
0
 def train():
     X, Y = self.loader.load_data(self.trainFileNames,
                                  max_len=Meta.max_string_len)
     model = NN.train(X, Y)
     model.save('../Model/model')
     self.log('结束训练')
     setState('ready')
示例#2
0
        def predict():
            model = NN.build()
            model.load('../Model/model')
            self.loader.load_dict()

            #sentences = [
            #    'The GREAT Billy Graham is dead. There was nobody like him! He will bemissed by Christians and all religions. A very special man.',
            #    'Billy Graham was a humble servant who prayed for SO many- and who, with wisdom and grace, gave hope and guidance to generations of Americans.'
            #]

            sentences = self.predictEdit.toPlainText().split('\n')
            results = predicts(model, sentences)
            self.log(str(results))
            idxs = list(np.argmax(results, axis=1))
            text = "\n".join([self.loader.personDictionary.lookup(idx) for idx in idxs])
            self.predictResultLabel.setText(text)
            self.log('结束预测')
            setState('ready')
示例#3
0
        def predict():
            model = NN.build()
            model.load('../Model/model')
            self.loader.load_dict()

            #sentences = [
            #    'The GREAT Billy Graham is dead. There was nobody like him! He will bemissed by Christians and all religions. A very special man.',
            #    'Billy Graham was a humble servant who prayed for SO many- and who, with wisdom and grace, gave hope and guidance to generations of Americans.'
            #]

            sentences = self.predictEdit.toPlainText().split('\n')
            results = predicts(model, sentences)
            self.log(str(results))
            idxs = list(np.argmax(results, axis=1))
            text = "\n".join(
                [self.loader.personDictionary.lookup(idx) for idx in idxs])
            self.predictResultLabel.setText(text)
            self.log('结束预测')
            setState('ready')
示例#4
0
文件: predict.py 项目: szsam/DSLearn
#     while True:
#         c_sk, c_addr = sk.accept()
#         print("Connection from: " + str(c_addr))
#         print('Waiting...')
#         data = c_sk.recv(1024).decode('utf-8')
#         if not data:
#             continue
#         print('Get: ' + data)
#         sentences_queue.put(data)
#         print('sentences number: ' + str(sentences_queue.qsize()))
#     c_sk.close()

# sentences_queue = Queue()

if __name__ == '__main__':
    model = NN.build()
    model.load('../Model/model')
    loader = Preprocessor()
    loader.load_dict()

    # sentences = [
    #    'The GREAT Billy Graham is dead. There was nobody like him! He will bemissed by Christians and all religions. A very special man.',
    #   'Billy Graham was a humble servant who prayed for SO many- and who, with wisdom and grace, gave hope and guidance to generations of Americans.'
    # ]

    # Thread(target=build_connection).start()

    sk = socket.socket()
    sk.bind((socket.gethostname(), 8080))
    sk.listen(1)
    while True:
示例#5
0
 def train():
     X, Y = self.loader.load_data(self.trainFileNames, max_len=Meta.max_string_len)
     model = NN.train(X, Y)
     model.save('../Model/model')
     self.log('结束训练')
     setState('ready')
示例#6
0
文件: main.py 项目: szsam/DSLearn
import Core.NN as NN
from Utils.Preprocessor import Preprocessor
import Utils.Meta as Meta

if __name__ == '__main__':
    p = Preprocessor()
    X, Y = p.load_data(
        ['../DataSet/BarackObama.csv', '../DataSet/DonaldTrumpTweets'],
        Meta.max_string_len)
    model = NN.train(X, Y)
    model.save('../Model/model')
示例#7
0
文件: main.py 项目: szsam/DSLearn
import Core.NN as NN
from Utils.Preprocessor import Preprocessor
import Utils.Meta as Meta

if __name__ == '__main__':
    p = Preprocessor()
    X, Y = p.load_data([
        '../DataSet/BarackObama.csv',
        '../DataSet/DonaldTrumpTweets'
    ], Meta.max_string_len)
    model = NN.train(X, Y)
    model.save('../Model/model')