[语音识别] 文本加标点--LSTM预测

2021-07-21 14:50:06 浏览数 (2)

文本加标点--训练BLSTM

bert4keras==0.5.9

代码语言:javascript复制
# -*- 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')# 忽略警告

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

def txt2p_model():
    # 模型构建
    model = Sequential()
    model.add(LSTM(256, input_shape=(None, 256),return_sequences=True)) 
    # model.add(LSTM(100, return_sequences=True)) 
    # model.add(Dropout(0.5)) #防止过拟合ÿ

0 人点赞