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

网站搭建服务器需要多少钱外包网站怎么做seo

网站搭建服务器需要多少钱,外包网站怎么做seo,程序员培训机构排名前十,wordpress 影响力系列文章 【如何训练一个中英翻译模型】LSTM机器翻译seq2seq字符编码#xff08;一#xff09; 【如何训练一个中英翻译模型】LSTM机器翻译模型训练与保存#xff08;二#xff09; 【如何训练一个中英翻译模型】LSTM机器翻译模型部署#xff08;三#xff09; 【如何训…系列文章 【如何训练一个中英翻译模型】LSTM机器翻译seq2seq字符编码一 【如何训练一个中英翻译模型】LSTM机器翻译模型训练与保存二 【如何训练一个中英翻译模型】LSTM机器翻译模型部署三 【如何训练一个中英翻译模型】LSTM机器翻译模型部署之onnxpython四 目录 系列文章1、加载字符文件2、加载权重文件3、推理模型搭建4、进行推理 模型部署也是很重要的一部分这里先讲基于python的部署后面我们还要将模型部署到移动端。 细心的小伙伴会发现前面的文章在模型保存之后进行模型推理时我们使用的数据是在训练之前我们对数据进行处理的encoder_input_data中读取而不是我们手动输入的那么这一章主要来解决自定义输入推理的问题 1、加载字符文件 首先我们根据 【如何训练一个中译英翻译器】LSTM机器翻译模型训练与保存二的操作到最后 会得到这样的三个文件input_words.txttarget_words.txtconfig.json 需要逐一进行加载 进行加载 # 加载字符 # 从 input_words.txt 文件中读取字符串 with open(input_words.txt, r) as f:input_words f.readlines()input_characters [line.rstrip(\n) for line in input_words]# 从 target_words.txt 文件中读取字符串 with open(target_words.txt, r, newline) as f:target_words [line.strip() for line in f.readlines()]target_characters [char.replace(\\t, \t).replace(\\n, \n) for char in target_words]#字符处理以方便进行编码 input_token_index dict([(char, i) for i, char in enumerate(input_characters)]) target_token_index dict([(char, i) for i, char in enumerate(target_characters)])# something readable. reverse_input_char_index dict((i, char) for char, i in input_token_index.items()) reverse_target_char_index dict((i, char) for char, i in target_token_index.items()) num_encoder_tokens len(input_characters) # 英文字符数量 num_decoder_tokens len(target_characters) # 中文文字数量读取配置文件 import json with open(config.json, r) as file:loaded_data json.load(file)# 从加载的数据中获取max_encoder_seq_length和max_decoder_seq_length的值 max_encoder_seq_length loaded_data[max_encoder_seq_length] max_decoder_seq_length loaded_data[max_decoder_seq_length]2、加载权重文件 # 加载权重 from keras.models import load_model encoder_model load_model(encoder_model.h5) decoder_model load_model(decoder_model.h5)3、推理模型搭建 def decode_sequence(input_seq):# Encode the input as state vectors.states_value encoder_model.predict(input_seq)# Generate empty target sequence of length 1.target_seq np.zeros((1, 1, num_decoder_tokens))# Populate the first character of target sequence with the start character.target_seq[0, 0, target_token_index[\t]] 1.# this target_seq you can treat as initial state# Sampling loop for a batch of sequences# (to simplify, here we assume a batch of size 1).stop_condition Falsedecoded_sentence while not stop_condition:output_tokens, h, c decoder_model.predict([target_seq] states_value)# Sample a token# argmax: Returns the indices of the maximum values along an axis# just like find the most possible charsampled_token_index np.argmax(output_tokens[0, -1, :])# find char using indexsampled_char reverse_target_char_index[sampled_token_index]# and append sentencedecoded_sentence sampled_char# Exit condition: either hit max length# or find stop character.if (sampled_char \n or len(decoded_sentence) max_decoder_seq_length):stop_condition True# Update the target sequence (of length 1).# append then ?# creating another new target_seq# and this time assume sampled_token_index to 1.0target_seq np.zeros((1, 1, num_decoder_tokens))target_seq[0, 0, sampled_token_index] 1.# Update states# update states, frome the front partsstates_value [h, c]return decoded_sentence4、进行推理 import numpy as npinput_text Call me. encoder_input_data np.zeros((1,max_encoder_seq_length, num_encoder_tokens),dtypefloat32) for t, char in enumerate(input_text):print(char)# 3D vector only z-index has char its value equals 1.0encoder_input_data[0,t, input_token_index[char]] 1.input_seq encoder_input_data decoded_sentence decode_sequence(input_seq) print(-) print(Input sentence:, input_text) print(Decoded sentence:, decoded_sentence)运行结果 以上的代码可在kaggle上运行how-to-train-a-chinese-to-english-translator-iii
http://www.zqtcl.cn/news/111458/

相关文章:

  • 网站维护界面设计做的网站一直刷新
  • 国外网站 国内访问速度土木工程毕业设计网站
  • 宿迁网站建设制作中国广告设计网
  • 上门做美容的有什么网站微信网页版本
  • 专门做餐饮运营的网站网站开发相关知识
  • 石家庄门户网站建设免费简历模板的网站
  • 微网站建设市场如何做好平台推广
  • 网站不备案做优化小程序开发前景怎么样
  • 美丽说网站优化百度关键词优化
  • 同性男做的视频网站赶集网招聘最新招聘附近找工作
  • 做挖机配件销售的网站oa办公系统软件哪家好
  • 聊城设计网站商务网站的特点
  • 厦门做个网站多少钱工程建设范围
  • 百度推广官方网站在哪里制作网页
  • 济南集团网站建设方案沈阳手机网站制作
  • 网站备案号注销的结果做网站的外包能学到什么
  • 在线购物网站开发项目网站建设电话推广话术
  • 网站主体信息太原站扩建
  • 西平县住房和城乡建设局网站空间商网站
  • p2p网站建设cms一键生成图片
  • 甘肃省第八建设集团公司网站能够做物理题的网站
  • 团购网站建设方案建筑工程网校官网
  • 佛山建站网站模板小公司管理方法
  • 常德住房和城乡建设局网站做风险代理案源的网站
  • 手机网站开发人员选项wordpress加载媒体库
  • 做钓鱼网站用哪种编程语言张家界有实力seo优化费用
  • 如何做一个主题网站做网站必须有框架么
  • 建设网站需要什么知识上海高端网页设计
  • 电子商务网站建设基本流程公司网站建设平台
  • 域名没过期 网站打不开怎么办素马设计顾问讲解价格