赞
踩
文本加标点--训练LSTM
keras版本:
- # -*- coding:utf-8 -*-
- import os
- import re
- import sys
- import time
- import jieba
- import gensim
- import logging
- import numpy as np
- import pandas as pd
- from tqdm import tqdm
- import multiprocessing
- from bert4keras.snippets import sequence_padding, DataGenerator
- from bert4keras.optimizers import Adam
- import warnings
- warnings.filterwarnings(action='ignore', category=UserWarning, module='gensim')# 忽略警告
- np.random.seed(2019)
-
- import keras
- from keras.models import *
- from keras.layers import *
- from keras.optimizers import *
- from keras.regularizers import l2
- from keras.callbacks import *
- from keras.optimizers import *
- from keras.callbacks import *
- from keras import backend as K
-
-
- # 超参数
- batch_size = 32
- learning_rate = 0.001
- epochs = 50
-
-
-
- def load_data(filename1, filename2):
- xlist = np.load('./wikiw2v.npy')
- ylist = np.load('./wikipunc.npy&#
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。