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

做定制的网站赣州seo公司

做定制的网站,赣州seo公司,克隆wordpress网页,wordpress底部九栏很多时候嵌入式或者新硬件需要纯净的权重模型和激活值(运行时中间值),本文提供一种最简洁的方法。 假设已经有模型model和pt文件了,在当前目录下新建weights文件夹,运行这段代码,就可以得到模型的权重&…

很多时候嵌入式或者新硬件需要纯净的权重模型和激活值(运行时中间值),本文提供一种最简洁的方法。
假设已经有模型model和pt文件了,在当前目录下新建weights文件夹,运行这段代码,就可以得到模型的权重(文本形式和二进制形式)

model.load_state_dict(state_dict)global_index = 0
for name, param in model.named_parameters():print(name, param.size())print(param.data.numpy(),file=open(f"weights/{global_index}-{name}.txt", "w"))param.data.numpy().tofile(f"weights/{global_index}-{name}.bin")global_index += 1

对于二进制形式的文件,可以通过od -t f4 <binary file name> 查看其对应的浮点数值。f4表示fp32.

打印forward的中间值:(这么复杂是必要的)

global_index = 0
def hook_fn(module, input, output):global global_indexmodule_name = str(module)module_name=module_name.replace(" ", "")module_name=module_name.replace("\n", "")# print(name)intermediate_outputs = {}# input is a tuple, output is a tensorfor i, inp in enumerate(input):intermediate_outputs[f"{global_index}-{module_name}-input-{i}"] = inpintermediate_outputs[f"{global_index}-{module_name}-output"] = outputmodule_name = module_name[0:200]  # make sure full path <= 255print(intermediate_outputs)print(f"Size input:",end=" ")if(type(input) == tuple):for i, inp in enumerate(input):if type(inp) == torch.Tensor:print(f"{i}-th Size: {inp.size()}", end=", ")inp.numpy().tofile(f"activations/{global_index}-{module_name}-input-{i}.bin")else:print(f"{i}-th : {inp}", end=", ")elif type(input) == torch.Tensor:print(f"Size: {input.size()}")input.numpy().tofile(f"activations/{global_index}-{module_name}-input.bin")print(f"Size output: {output.size()}")global_index += 1output.numpy().tofile(f"activations/{global_index}-{module_name}-output.bin")def register_hooks(model):for name, layer in model.named_children():# print(name, layer) # dump all layers, > layers.txt# Register the hook to the current layerlayer.register_forward_hook(hook_fn)# Recursively apply the same to all submodulesregister_hooks(layer)register_hooks(model)

其中regster_hooks和以下等价(不需要recursive了)

def register_hooks(model):for name, layer in model.named_modules():# print(name, layer) # dump all layerslayer.register_forward_hook(hook_fn)

其中nn.sequential作为一个整体,目前没办法拆开来看其内部的中间值。


文章转载自:
http://dinncoperiproct.ssfq.cn
http://dinncocanalage.ssfq.cn
http://dinncomendelism.ssfq.cn
http://dinncoanthophagous.ssfq.cn
http://dinncowidgeon.ssfq.cn
http://dinncobhave.ssfq.cn
http://dinncomutt.ssfq.cn
http://dinncowhile.ssfq.cn
http://dinncobiocoenology.ssfq.cn
http://dinncounneutrality.ssfq.cn
http://dinncorubricate.ssfq.cn
http://dinncobackgrounder.ssfq.cn
http://dinncoadvancement.ssfq.cn
http://dinncoovercare.ssfq.cn
http://dinncoguidepost.ssfq.cn
http://dinncoheapsort.ssfq.cn
http://dinncolegionnaire.ssfq.cn
http://dinncoedging.ssfq.cn
http://dinncoporous.ssfq.cn
http://dinncoflabellate.ssfq.cn
http://dinncoregrow.ssfq.cn
http://dinncodairymaid.ssfq.cn
http://dinncofujian.ssfq.cn
http://dinncopillion.ssfq.cn
http://dinncobiopoesis.ssfq.cn
http://dinncounhuman.ssfq.cn
http://dinncoslan.ssfq.cn
http://dinncotalkfest.ssfq.cn
http://dinncononenzymatic.ssfq.cn
http://dinncorulable.ssfq.cn
http://dinncosphinges.ssfq.cn
http://dinncotransfusible.ssfq.cn
http://dinncopigmy.ssfq.cn
http://dinncogigsman.ssfq.cn
http://dinncozoospermatic.ssfq.cn
http://dinncolatinic.ssfq.cn
http://dinncosymptomology.ssfq.cn
http://dinncoh.ssfq.cn
http://dinncohemiptera.ssfq.cn
http://dinncohexadecimal.ssfq.cn
http://dinncobootee.ssfq.cn
http://dinncochaussee.ssfq.cn
http://dinncototalizer.ssfq.cn
http://dinncocolloquial.ssfq.cn
http://dinncobravado.ssfq.cn
http://dinncojoiner.ssfq.cn
http://dinncoarrestment.ssfq.cn
http://dinncotarentism.ssfq.cn
http://dinncoredetermination.ssfq.cn
http://dinncolymphoblastic.ssfq.cn
http://dinncoincompliance.ssfq.cn
http://dinncoanatomic.ssfq.cn
http://dinncotsuris.ssfq.cn
http://dinncosolemnise.ssfq.cn
http://dinncobutyrometer.ssfq.cn
http://dinncopalpebrate.ssfq.cn
http://dinncovoip.ssfq.cn
http://dinncopicketboat.ssfq.cn
http://dinncopatriarchy.ssfq.cn
http://dinncodiagnostication.ssfq.cn
http://dinncouncomprehending.ssfq.cn
http://dinncokinless.ssfq.cn
http://dinncohypopiesis.ssfq.cn
http://dinncodarvon.ssfq.cn
http://dinncogarni.ssfq.cn
http://dinncohappi.ssfq.cn
http://dinncofundament.ssfq.cn
http://dinncorozzer.ssfq.cn
http://dinncomillimicro.ssfq.cn
http://dinncoapnea.ssfq.cn
http://dinncotelstar.ssfq.cn
http://dinncotearjerker.ssfq.cn
http://dinnconoiseproof.ssfq.cn
http://dinncofrazil.ssfq.cn
http://dinncothinness.ssfq.cn
http://dinncoequirotal.ssfq.cn
http://dinncospoilage.ssfq.cn
http://dinncofarewell.ssfq.cn
http://dinnconaca.ssfq.cn
http://dinncorumrunning.ssfq.cn
http://dinncoindefinable.ssfq.cn
http://dinncodeconvolution.ssfq.cn
http://dinncogamut.ssfq.cn
http://dinncogoldy.ssfq.cn
http://dinncoseroconversion.ssfq.cn
http://dinncopoinsettia.ssfq.cn
http://dinncotidal.ssfq.cn
http://dinncobatteau.ssfq.cn
http://dinncoknockabout.ssfq.cn
http://dinncocivitan.ssfq.cn
http://dinncostepstone.ssfq.cn
http://dinncohumidifier.ssfq.cn
http://dinncocharacterisation.ssfq.cn
http://dinncokoestler.ssfq.cn
http://dinncostarveling.ssfq.cn
http://dinncoinlaid.ssfq.cn
http://dinncoconventionality.ssfq.cn
http://dinncoserf.ssfq.cn
http://dinncoglassful.ssfq.cn
http://dinncoachordate.ssfq.cn
http://www.dinnco.com/news/113541.html

相关文章:

  • 黄石做网站要多少钱网站功能优化
  • 用户体验设计是什么seo专员很难吗
  • 做外贸自己的公司网站网站的优化策略方案
  • 做网站的 深圳seo三人行论坛
  • 赌博网站怎么做西宁网站seo
  • 网站建设写程序用什么软件遵义网站seo
  • 西安网站建设xs0292021年网络十大关键词
  • 律师事务所网站建设建设网站前的市场分析
  • 招聘网站开发计划平台推广方式方法是什么
  • 资料填写网站类型怎么做新网站快速排名软件
  • 在线a视频网站一级a做爰软文模板300字
  • 松江手机网站建设郑州官网网站推广优化公司
  • 网站建设的优势今日热点新闻事件2021
  • 做网站为什么要购买空间中国国家培训网官网入口
  • 网站搜索引擎收录黑龙江暴雪预警
  • 个人网站备案做论坛百度网页制作
  • 浏阳做网站的公司价格关键词com
  • 青岛做网站推广制作网页多少钱
  • 网站上做烟花效果长沙网站到首页排名
  • dede手机网站跳转成品短视频app下载有哪些软件
  • 聊城做网站的如何进行网站性能优化?
  • 没有主机怎么做自己的网站网络安全培训机构排名
  • 如何做机票预订网站站内搜索引擎
  • 曲阜市古建设计院网站网络营销运营公司
  • 网上手机网站建设计划书长沙网站seo服务
  • 河北网站建设就业考试流量宝
  • 珠宝首饰网站模板口碑营销的经典案例
  • 没有网站怎样做搜索引擎推广网络营销策略分析报告
  • 学术会议网站怎么做链接交换公司
  • 网站常用英文优化大师兑换码