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

北京海淀区有哪些企业网络营销乐云seo

北京海淀区有哪些企业,网络营销乐云seo,特色的佛山网站建设,哪个网站做职客比较好 比较正规Hugging Face, EleutherAI, StabilityAI 用的多 介绍 文件形式 header,体现其特性。如果强行将pickle或者空软连接 打开,会出现报错。解决详见:debug 连接到其他教程结构和参数 安装 with pip:Copied pip install safetensors with con…

Hugging Face, EleutherAI, StabilityAI 用的多

介绍

文件形式

  • header,体现其特性。如果强行将pickle或者空软连接 打开,会出现报错。解决详见:debug 连接到其他教程
  • 结构和参数
    数据结构

安装

with pip:Copied
pip install safetensors
with conda:Copied
conda install -c huggingface safetensors

Usage

文档: https://huggingface.co/docs/safetensors/index
github: https://github.com/huggingface/safetensors

测试安装

import torch
from safetensors import safe_open
from safetensors.torch import save_filetensors = {"weight1": torch.zeros((1024, 1024)),"weight2": torch.zeros((1024, 1024))
}
save_file(tensors, "model.safetensors")tensors = {}
with safe_open("model.safetensors", framework="pt", device="cpu") as f:for key in f.keys():tensors[key] = f.get_tensor(key)

加载

文档 https://huggingface.co/docs/diffusers/using-diffusers/using_safetensors

from diffusers import StableDiffusionPipelinepipeline = StableDiffusionPipeline.from_single_file("https://huggingface.co/WarriorMama777/OrangeMixs/blob/main/Models/AbyssOrangeMix/AbyssOrangeMix.safetensors"
)

Load tensors


from safetensors import safe_opentensors = {}
with safe_open("model.safetensors", framework="pt", device=0) as f:for k in f.keys():tensors[k] = f.get_tensor(k)
# Loading only part of the tensors (interesting when running on multiple GPU)from safetensors import safe_opentensors = {}
with safe_open("model.safetensors", framework="pt", device=0) as f:tensor_slice = f.get_slice("embedding")vocab_size, hidden_dim = tensor_slice.get_shape()tensor = tensor_slice[:, :hidden_dim]

保存


import torch
from safetensors.torch import save_filetensors = {"embedding": torch.zeros((2, 2)),"attention": torch.zeros((2, 3))
}
save_file(tensors, "model.safetensors")

转换到safetensor

  • 在线,利用hugging face

The easiest way to convert your model weights is to use the Convert Space, given your model weights are already stored on the Hub. The Convert Space downloads the pickled weights, converts them, and opens a Pull Request to upload the newly converted .safetensors file to your repository.

  • 本地 运行
    see 转换代码 convert.py
# 主函数
def convert_file(pt_filename: str,sf_filename: str,
):loaded = torch.load(pt_filename, map_location="cpu")if "state_dict" in loaded:loaded = loaded["state_dict"]shared = shared_pointers(loaded)for shared_weights in shared:for name in shared_weights[1:]:loaded.pop(name)# For tensors to be contiguousloaded = {k: v.contiguous() for k, v in loaded.items()}dirname = os.path.dirname(sf_filename)os.makedirs(dirname, exist_ok=True)save_file(loaded, sf_filename, metadata={"format": "pt"})check_file_size(sf_filename, pt_filename)reloaded = load_file(sf_filename)for k in loaded:pt_tensor = loaded[k]sf_tensor = reloaded[k]if not torch.equal(pt_tensor, sf_tensor):raise RuntimeError(f"The output tensors do not match for key {k}")

例子

解析

import requests # pip install requests
import structdef parse_single_file(url):# Fetch the first 8 bytes of the fileheaders = {'Range': 'bytes=0-7'}response = requests.get(url, headers=headers)# Interpret the bytes as a little-endian unsigned 64-bit integerlength_of_header = struct.unpack('<Q', response.content)[0]# Fetch length_of_header bytes starting from the 9th byteheaders = {'Range': f'bytes=8-{7 + length_of_header}'}response = requests.get(url, headers=headers)# Interpret the response as a JSON objectheader = response.json()return headerurl = "https://huggingface.co/gpt2/resolve/main/model.safetensors"
header = parse_single_file(url)print(header)
http://www.hrbkazy.com/news/7486.html

相关文章:

  • 音乐网站建设价格莆田网站建设优化
  • 一个网站交互怎么做的进行seo网站建设
  • 制作网站的程序网站生成app工具
  • 网站建设bz3399seo门户网站建设方案
  • 网站中的作用怎么创作自己的网站
  • 字体在线生成器济南seo的排名优化
  • 素材最多的网站营销策略有哪几种
  • 广州交易中心搜索引擎优化的英文
  • 化妆品网站html模板常州网站优化
  • 微信做网站的公司seo实战密码
  • 济南企业做网站网站搭建需要多少钱?
  • b站推广入口2024mmmseo网络营销招聘
  • 短视频营销ppt上海关键词排名优化怎样
  • 全国各大知名网站文案代写在哪里接单子
  • 百度云搜索引擎网站武汉网站建设推广公司
  • 找生意做去哪个网站广州网站营销推广
  • 用网站做宣传的费用seo外包大型公司
  • 品牌策划公司网站seo搜索优化公司
  • 俄文网站商城建设自己建个网站要多少钱
  • 有了域名如何建设网站百度账户代运营
  • 做彩票网站要多少钱北京官网seo
  • 想建一个网站怎么做电子商务网站设计方案
  • 建设网站网站设计seo点击优化
  • 网站模版防被偷搜索引擎营销的主要方式有哪些?
  • wordpress分页代码百度推广优化师培训
  • 营销型网站服务行业数据统计网站
  • 高端网站建设报价北京全网推广
  • 网站开发流程丽江怎样做好网络推广呀
  • 宁波网站建设哪家比较好权重查询入口
  • 网站 备案 哪个省代做seo关键词排名