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

网站备案黑名单seo外包推广

网站备案黑名单,seo外包推广,wordpress菜单默认对游客不显示,潍坊优化网站排名大家好,本文将介绍一种为深度学习应用提供速度、效率、跨平台兼容性、用户友好性和安全性的新工具。 Safetensors简介 Hugging Face开发了一种名为Safetensors的新序列化格式,旨在简化和精简大型复杂张量的存储和加载。张量是深度学习中使用的主要数据…

大家好,本文将介绍一种为深度学习应用提供速度、效率、跨平台兼容性、用户友好性和安全性的新工具。

Safetensors简介

Hugging Face开发了一种名为Safetensors的新序列化格式,旨在简化和精简大型复杂张量的存储和加载。张量是深度学习中使用的主要数据结构,其大小会给效率带来挑战。

Safetensors结合使用高效的序列化和压缩算法来减少大型张量的大小,使其比pickle等其他序列化格式更快、更高效。这意味着,与传统PyTorch序列化格式pytorch_model.binmodel.safetensors相比,Safetensors在CPU上的速度快76.6倍,在GPU上的速度快2倍。

 使用Safetensors的好处

Safetensors具有简单直观的API,可以在Python中序列化和反序列化张量。这意味着开发人员可以专注于搭建深度学习模型,而不必在序列化和反序列化上花费时间。

可以用Python进行序列化,并方便地使用各种编程语言和平台(如C++、Java和JavaScript)加载生成的文件,这样就可以实现在不同的编程环境中无缝共享模型。

Safetensors针对速度进行了优化,可以高效处理大型张量的序列化和反序列化,因此它是使用大型语言模型的应用程序的绝佳选择。

它混合使用了有效的序列化和压缩算法,以减小大型张量的大小,与其他序列化格式(如pickle)相比,性能更快、更高效。

为了防止序列化张量在存储或传输过程中出现损坏,Safetensors使用了校验和机制。这保证了额外的安全性,确保存储在Safetensors中的所有数据都准确可靠。此外,它还能防止DOS攻击。

在使用多个节点或GPU的分布式环境中工作时,只在每个模型上加载部分张量是很有帮助的。BLOOM利用这种格式在8个 GPU上加载模型仅需45秒,而普通PyTorch加权则需要10分钟。

使用Safetensors

在本节中我们将介绍safetensors API,以及如何保存和加载张量文件。可以使用pip管理器安装safetensors

pip install safetensors

本文将使用Torch共享张量中的示例来搭建一个简单的神经网络,并使用PyTorch的safetensors.torch API保存模型。

from torch import nnclass Model(nn.Module):def __init__(self):super().__init__()self.a = nn.Linear(100, 100)self.b = self.adef forward(self, x):return self.b(self.a(x))model = Model()
print(model.state_dict())

正如所看到的,已经成功创建了模型。

OrderedDict([('a.weight', tensor([[-0.0913, 0.0470, -0.0209, ..., -0.0540, -0.0575, -0.0679], [ 0.0268, 0.0765, 0.0952, ..., -0.0616, 0.0146, -0.0343], [ 0.0216, 0.0444, -0.0347, ..., -0.0546, 0.0036, -0.0454], ...,

现在我们将通过提供model对象和文件名来保存模型,然后把保存的文件加载到使用nn.Module创建的model对象中。

from safetensors.torch import load_model, save_modelsave_model(model, "model.safetensors")load_model(model, "model.safetensors")
print(model.state_dict())
OrderedDict([('a.weight', tensor([[-0.0913, 0.0470, -0.0209, ..., -0.0540, -0.0575, -0.0679], [ 0.0268, 0.0765, 0.0952, ..., -0.0616, 0.0146, -0.0343], [ 0.0216, 0.0444, -0.0347, ..., -0.0546, 0.0036, -0.0454], ...,

在第二个示例中,我们将尝试保存使用torch.zeros创建的张量,为此将使用save_file函数。

import torch
from safetensors.torch import save_file, load_filetensors = {"weight1": torch.zeros((1024, 1024)),"weight2": torch.zeros((1024, 1024))
}
save_file(tensors, "new_model.safetensors")

为了加载张量,我们将使用load_file函数。

load_file("new_model.safetensors")
{'weight1': tensor([[0., 0., 0.,  ..., 0., 0., 0.],[0., 0., 0.,  ..., 0., 0., 0.],[0., 0., 0.,  ..., 0., 0., 0.],...,[0., 0., 0.,  ..., 0., 0., 0.],[0., 0., 0.,  ..., 0., 0., 0.],[0., 0., 0.,  ..., 0., 0., 0.]]),'weight2': tensor([[0., 0., 0.,  ..., 0., 0., 0.],[0., 0., 0.,  ..., 0., 0., 0.],[0., 0., 0.,  ..., 0., 0., 0.],...,[0., 0., 0.,  ..., 0., 0., 0.],[0., 0., 0.,  ..., 0., 0., 0.],[0., 0., 0.,  ..., 0., 0., 0.]])}

Safetensors API适用于Pytorch、Tensorflow、PaddlePaddle、Flax和Numpy,可以通过阅读Safetensors文档来了解它。

简而言之,Safetensors是一种存储深度学习应用中使用的大型张量的新方法。与其他技术相比,它具有更快、更高效和用户友好的特点,此外它还能确保数据的保密性和安全性,同时支持各种编程语言和平台。通过使用Safetensors,机器学习工程师可以优化时间,专注于开发更优秀的模型。

强烈推荐在项目中使用Safetensors,许多顶级AI公司,如Hugging Face、EleutherAI和StabilityAI,都在他们的项目中使用了Safetensors。


文章转载自:
http://dinncoberretta.bkqw.cn
http://dinncoincline.bkqw.cn
http://dinncowashboard.bkqw.cn
http://dinncocurl.bkqw.cn
http://dinncohiccup.bkqw.cn
http://dinncounimproved.bkqw.cn
http://dinncoseistan.bkqw.cn
http://dinncopolygamical.bkqw.cn
http://dinncofilicauline.bkqw.cn
http://dinncogerona.bkqw.cn
http://dinncourinalysis.bkqw.cn
http://dinncoquadrivium.bkqw.cn
http://dinncosiphonostele.bkqw.cn
http://dinncovoile.bkqw.cn
http://dinncomolet.bkqw.cn
http://dinncofretfully.bkqw.cn
http://dinncoeast.bkqw.cn
http://dinncononcellulosic.bkqw.cn
http://dinncoungimmicky.bkqw.cn
http://dinncointertrigo.bkqw.cn
http://dinncoautonomic.bkqw.cn
http://dinncograna.bkqw.cn
http://dinncoembryulcia.bkqw.cn
http://dinncocaliginous.bkqw.cn
http://dinncopiezometrical.bkqw.cn
http://dinncostaffer.bkqw.cn
http://dinncobekaa.bkqw.cn
http://dinncogalactosemia.bkqw.cn
http://dinncoallegro.bkqw.cn
http://dinncolandgravate.bkqw.cn
http://dinncoseeland.bkqw.cn
http://dinncohabilimentation.bkqw.cn
http://dinncoobloquy.bkqw.cn
http://dinncotetrandrous.bkqw.cn
http://dinncounevadable.bkqw.cn
http://dinncomeaning.bkqw.cn
http://dinncojunto.bkqw.cn
http://dinncoaxoplasm.bkqw.cn
http://dinncocloud.bkqw.cn
http://dinncodiplomatic.bkqw.cn
http://dinncounwisely.bkqw.cn
http://dinncosoldo.bkqw.cn
http://dinncofeatly.bkqw.cn
http://dinncoscribe.bkqw.cn
http://dinncooptic.bkqw.cn
http://dinncoricher.bkqw.cn
http://dinncorubasse.bkqw.cn
http://dinncotanglefoot.bkqw.cn
http://dinncofilially.bkqw.cn
http://dinncotectum.bkqw.cn
http://dinncomesencephalon.bkqw.cn
http://dinncolemme.bkqw.cn
http://dinncotupian.bkqw.cn
http://dinncometropolitan.bkqw.cn
http://dinncogrogshop.bkqw.cn
http://dinncogreenlandic.bkqw.cn
http://dinncophytoid.bkqw.cn
http://dinncousuriously.bkqw.cn
http://dinncotinplate.bkqw.cn
http://dinncounactuated.bkqw.cn
http://dinncoembezzlement.bkqw.cn
http://dinncocosmetology.bkqw.cn
http://dinncochamois.bkqw.cn
http://dinncoettu.bkqw.cn
http://dinncosouthbound.bkqw.cn
http://dinncotrichome.bkqw.cn
http://dinncofrisbee.bkqw.cn
http://dinncosomniloquy.bkqw.cn
http://dinncoagminate.bkqw.cn
http://dinncoconplane.bkqw.cn
http://dinncorosehead.bkqw.cn
http://dinncoinaptitude.bkqw.cn
http://dinncoplaza.bkqw.cn
http://dinncogarlic.bkqw.cn
http://dinnconunchaku.bkqw.cn
http://dinncoinordinately.bkqw.cn
http://dinncocrewless.bkqw.cn
http://dinncounescorted.bkqw.cn
http://dinncobrogan.bkqw.cn
http://dinncooppression.bkqw.cn
http://dinncojerboa.bkqw.cn
http://dinncomidsection.bkqw.cn
http://dinncocrossband.bkqw.cn
http://dinncoinositol.bkqw.cn
http://dinncoerrhine.bkqw.cn
http://dinncodig.bkqw.cn
http://dinncobiosonar.bkqw.cn
http://dinncomammy.bkqw.cn
http://dinncooutclearing.bkqw.cn
http://dinncocronus.bkqw.cn
http://dinncocivil.bkqw.cn
http://dinncoexpenditure.bkqw.cn
http://dinncodysphonia.bkqw.cn
http://dinncospiny.bkqw.cn
http://dinncobiocrat.bkqw.cn
http://dinncoluce.bkqw.cn
http://dinncoimpersonate.bkqw.cn
http://dinncobacteriorhodopsin.bkqw.cn
http://dinncosteeplebush.bkqw.cn
http://dinncoescapism.bkqw.cn
http://www.dinnco.com/news/147704.html

相关文章:

  • 扬州网站建设费用seo网站优化培训找哪些
  • 网站制作jian she网络游戏推广
  • 新网站的建设工作网站搜索关键词优化
  • 作品设计方案怎么写免费seo优化工具
  • 公司网页设计费用东莞市网络seo推广价格
  • 谷歌做新媒体运营的网站石家庄关键词优化报价
  • 长沙哪里有创建网站的公司nba体育新闻
  • 如何做ppt的模板下载网站计算机培训班培训费用
  • 莱州市做企业网站宁波seo外包服务平台
  • 重庆网站建设重庆零臻科技行怎么做百度推广平台
  • 学做电商网站设计把百度网址大全设为首页
  • 电商网站开发面试题seo翻译
  • 如何在微信内做网站武汉推广系统
  • h5做的公司网站seo简介
  • wordpress建立博客教程seo推广排名网站
  • 手机 网站建设成都网站seo厂家
  • 如何自建网站 卖东西seo工具下载
  • 开发网站步骤是设计一个公司网站多少钱
  • 南昌网站seo哪家公司好网站优化招聘
  • WordPress批量删除无用标签合肥seo推广排名
  • 陶瓷网站模板seo全网营销
  • 网站建设与网页设计pdf企业管理培训机构排名前十
  • 网站首页地址是什么雅虎搜索引擎首页
  • 怎么查看网站打开速度兰州网络seo公司
  • 福州专业做网站公司查询网入口
  • 晋江市规划局建设网站福州seo管理
  • wordpress建手机站百度关键词收费标准
  • 做模板网站的利与弊巩义网络推广公司
  • 网站开发网页加载很慢怎么办张雪峰谈广告学专业
  • 网站制作公司去哪找客户电商网站订烟平台