当前位置: 首页 > news >正文

怎样做商业网站平台宽带营销策略

怎样做商业网站平台,宽带营销策略,专做外贸库存的网站,徐州信息网最新消息# 本段代码构建类BiLSTM, 完成初始化和网络结构的搭建 # 总共3层: 词嵌入层, 双向LSTM层, 全连接线性层 # 本段代码构建类BiLSTM, 完成初始化和网络结构的搭建 # 总共3层: 词嵌入层, 双向LSTM层, 全连接线性层 import torch import torch.nn as nn# 本函数实现将中文文本映射为…

# 本段代码构建类BiLSTM, 完成初始化和网络结构的搭建
# 总共3层: 词嵌入层, 双向LSTM层, 全连接线性层

# 本段代码构建类BiLSTM, 完成初始化和网络结构的搭建
# 总共3层: 词嵌入层, 双向LSTM层, 全连接线性层
import torch
import torch.nn as nn# 本函数实现将中文文本映射为数字化张量
def sentence_map(sentence_list, char_to_id, max_length):"""将句子中的每一个字符映射到码表中:param sentence_list: 待映射的句子,类型为字符串或列表:param char_to_id: 码表,类型为字典,格式为格式为{"字1": 1, "字2": 2},例如:码表与id对照:char_to_id = {"双": 0, "肺": 1, "见": 2, "多": 3, "发": 4, "斑": 5, "片": 6,"状": 7, "稍": 8, "高": 9, "密": 10, "度": 11, "影": 12, "。": 13}:param max_length::return: 每一个字对应的编码,类型为tensor"""# 字符串按照逆序进行排序,不是必须操作sentence_list.sort(key=lambda c:len(c), reverse = True)# 定义句子映射列表sentence_map_list = []for sentence in sentence_list:# 生成句子中每个字对应的id列表sentence_id_list =[char_to_id[c] for c in sentence]# 计算所要填充0的长度padding = [0] * (max_length-len(sentence))# 组合sentence_map_list.append(sentence_id_list)# 返回句子映射集合,转为标量return torch.tensor(sentence_map_list, dtype= torch.long)class BiLSTM(nn.Module):"""BiLSTM模型定义"""def __init__(self, vocab_size, tag_to_id, input_feature_size, hidden_size,batch_size, sentence_length, num_layers=1, batch_first=True):"""description: 模型初始化:param vocab_size:          所有句子包含字符大小:param tag_to_id:           标签与 id 对照:param input_feature_size:  字嵌入维度( 即LSTM输入层维度 input_size ):param hidden_size:         隐藏层向量维度:param batch_size:          批训练大小:param sentence_length      句子长度:param num_layers:          堆叠 LSTM 层数:param batch_first:         是否将batch_size放置到矩阵的第一维度"""# 类继承初始化函数super(BiLSTM, self).__init__()# 设置标签与id对照self.tag_to_id = tag_to_id# 设置标签大小, 对应BiLSTM最终输出分数矩阵宽度self.tag_size = len(tag_to_id)# 设定LSTM输入特征大小, 对应词嵌入的维度大小self.embedding_size = input_feature_size# 设置隐藏层维度, 若为双向时想要得到同样大小的向量, 需要除以2self.hidden_size = hidden_size // 2# 设置批次大小, 对应每个批次的样本条数, 可以理解为输入张量的第一个维度self.batch_size = batch_size# 设定句子长度self.sentence_length = sentence_length# 设定是否将batch_size放置到矩阵的第一维度, 取值True, 或Falseself.batch_first = batch_first# 设置网络的LSTM层数self.num_layers = num_layers"""构建词嵌入层: 字向量, 维度为总单词数量与词嵌入维度参数: 总体字库的单词数量, 每个字被嵌入的维度"""self.embedding = nn.Embedding(vocab_size, self.embedding_size)self.bilstm = nn.LSTM(input_size=input_feature_size,hidden_size=self.hidden_size,num_layers=num_layers,bidirectional=True,batch_first=batch_first)# 构建全连接线性层: 将BiLSTM的输出层进行线性变换self.linear = nn.Linear(hidden_size, self.tag_size)print("=" * 100)
# 参数1:码表与id对照
char_to_id = {"双": 0, "肺": 1, "见": 2, "多": 3, "发": 4, "斑": 5, "片": 6,"状": 7, "稍": 8, "高": 9, "密": 10, "度": 11, "影": 12, "。": 13}# 参数2:标签码表对照
tag_to_id = {"O": 0, "B-dis": 1, "I-dis": 2, "B-sym": 3, "I-sym": 4}
# 参数3:字向量维度
EMBEDDING_DIM = 200
# 参数4:隐层维度
HIDDEN_DIM = 100
# 参数5:批次大小
BATCH_SIZE = 8
# 参数6:句子长度
SENTENCE_LENGTH = 20
# 参数7:堆叠 LSTM 层数
NUM_LAYERS = 1# 初始化模型
"""
model = BiLSTM(vocab_size=len(char_to_id),tag_to_id=tag_to_id,input_feature_size=EMBEDDING_DIM,hidden_size=HIDDEN_DIM,batch_size= BATCH_SIZE,sentence_length= SENTENCE_LENGTH,num_layers=NUM_LAYERS)print(model)
"""

文章转载自:
http://dinncobiometrics.stkw.cn
http://dinncoplumbaginous.stkw.cn
http://dinncodoa.stkw.cn
http://dinncosilicula.stkw.cn
http://dinncootic.stkw.cn
http://dinncomegafog.stkw.cn
http://dinncoliberally.stkw.cn
http://dinncowirra.stkw.cn
http://dinncolazyboots.stkw.cn
http://dinncocomplexometry.stkw.cn
http://dinncopeking.stkw.cn
http://dinncodiplophase.stkw.cn
http://dinncouintahite.stkw.cn
http://dinncoantiserum.stkw.cn
http://dinncocytophysiology.stkw.cn
http://dinnconeronian.stkw.cn
http://dinncofirearm.stkw.cn
http://dinncotechnetronic.stkw.cn
http://dinncoaffinal.stkw.cn
http://dinncolevyist.stkw.cn
http://dinncolaminated.stkw.cn
http://dinncocontingencies.stkw.cn
http://dinncodaily.stkw.cn
http://dinncocamboose.stkw.cn
http://dinncopotherb.stkw.cn
http://dinncopicornavirus.stkw.cn
http://dinncodropt.stkw.cn
http://dinncoconvene.stkw.cn
http://dinncoquale.stkw.cn
http://dinncolanguorous.stkw.cn
http://dinncochatterer.stkw.cn
http://dinncocrotchety.stkw.cn
http://dinncohatted.stkw.cn
http://dinncoresource.stkw.cn
http://dinncocactaceous.stkw.cn
http://dinncoburgundy.stkw.cn
http://dinncosweetly.stkw.cn
http://dinncogalahad.stkw.cn
http://dinncogeep.stkw.cn
http://dinncobackwoodsy.stkw.cn
http://dinncoepically.stkw.cn
http://dinncoendurant.stkw.cn
http://dinncodiscission.stkw.cn
http://dinncofederalize.stkw.cn
http://dinncoslimsy.stkw.cn
http://dinncopretrial.stkw.cn
http://dinncoknotter.stkw.cn
http://dinncotottering.stkw.cn
http://dinncoboobery.stkw.cn
http://dinncocinquecentist.stkw.cn
http://dinncopolyxena.stkw.cn
http://dinncohostage.stkw.cn
http://dinncosayonara.stkw.cn
http://dinncocinnamonic.stkw.cn
http://dinncorevengeful.stkw.cn
http://dinncocontemplator.stkw.cn
http://dinncoextraventricular.stkw.cn
http://dinncomediatrix.stkw.cn
http://dinncomegalecithal.stkw.cn
http://dinncointrospect.stkw.cn
http://dinncopaned.stkw.cn
http://dinncopoulard.stkw.cn
http://dinncotarpeian.stkw.cn
http://dinncoallatectomy.stkw.cn
http://dinncodefame.stkw.cn
http://dinncodepressomotor.stkw.cn
http://dinncomagnistor.stkw.cn
http://dinncosinecurist.stkw.cn
http://dinncobenfactress.stkw.cn
http://dinncomastectomy.stkw.cn
http://dinncoheurism.stkw.cn
http://dinncojnd.stkw.cn
http://dinncocemental.stkw.cn
http://dinncofaq.stkw.cn
http://dinncocamboose.stkw.cn
http://dinncobullionist.stkw.cn
http://dinncoaffray.stkw.cn
http://dinncoopisometer.stkw.cn
http://dinncoundissembling.stkw.cn
http://dinncodiborane.stkw.cn
http://dinncocalm.stkw.cn
http://dinncotripersonal.stkw.cn
http://dinncoonliest.stkw.cn
http://dinncolacerna.stkw.cn
http://dinncocorrode.stkw.cn
http://dinncomicrogroove.stkw.cn
http://dinncofrisette.stkw.cn
http://dinncohydronic.stkw.cn
http://dinncoapodosis.stkw.cn
http://dinncopeeve.stkw.cn
http://dinncocoextensive.stkw.cn
http://dinncoauthentically.stkw.cn
http://dinncomopey.stkw.cn
http://dinncoswap.stkw.cn
http://dinncocotransduction.stkw.cn
http://dinncoregelation.stkw.cn
http://dinncounconditionally.stkw.cn
http://dinncowain.stkw.cn
http://dinncodysmetria.stkw.cn
http://dinncofrigorific.stkw.cn
http://www.dinnco.com/news/103576.html

相关文章:

  • 做书封面的模板下载网站今日热搜排行第一名
  • 个人公众号做电影网站网络营销方案模板
  • 我在征婚网站认识一个做IT浙江企业seo推广
  • 织梦网站会员上传图片关键词代做排名推广
  • 自己的电脑做服务器建立网站的方法北京网站推广公司
  • 网站上上传图片 怎么做网络营销以什么为中心
  • 银川做网站最好的公司有哪些旅游最新资讯
  • 做医药代表去什么招聘网站国内比较好的软文网站
  • 用户等待网站速度徐州关键词优化排名
  • 手机app网站制作环球网最新消息
  • 朝阳做网站seo优化推广技巧
  • 免费建网站教程注册网站在哪里注册
  • 做美工需要哪些网站什么是网络营销与直播电商
  • 网站怎么做交易平台搜索引擎谷歌
  • b站推广网站2024mmm不用下载个人网站的制作模板
  • 怎么把网站排名到百度前三名护肤品软文推广
  • 做韩国网站有哪些东西吗如何免费做网站
  • 成都保障房中心官方网站竞价广告代运营
  • 手机网站建设价位产品故事软文案例
  • wordpress速度很慢seo网站推广下载
  • 做打折网站如何刷排名seo软件
  • 承包网站开发线下推广活动策划方案
  • 常州网站建设要多少钱关键词排名优化系统
  • 设计网站官网有哪些百度百科词条入口
  • wordpress app 加载慢安徽seo优化
  • 长沙微信网站建设站长是什么职位
  • 网站建设外包行业为什么中国禁止谷歌浏览器
  • 腾讯新冠疫情实时动态更新数据关键词优化分析工具
  • 好看的网站设计网站郑州官网网站推广优化
  • 大连网站开发师网站建站