神经网络模型计算工具:FLOPs、MACs和参数量分析
calflops是一款专为神经网络模型设计的计算工具,可分析各类模型的FLOPs、MACs和参数量。支持线性、CNN、RNN、GCN和Transformer等模型,以及基于PyTorch的自定义模型。工具能详细展示每个子模块的计算数据及占比,有助于深入了解模型性能。对大型语言模型的分析尤为出色,并与Hugging Face平台无缝对接。
这个工具(calflops)旨在计算各种神经网络的理论FLOPs(浮点运算次数)、MACs(乘加运算次数)和参数数量,适用于线性层、CNN、RNN、GCN、Transformer(如Bert、LlaMA等大型语言模型),甚至包括任何基于PyTorch实现的自定义模型,只要使用了torch.nn.function.*
。同时,该工具支持打印模型每个子模块的FLOPS、参数计算值和比例,方便用户了解模型各部分的性能消耗。
最新消息,calflops已在Huggingface Space上推出了一个工具,可以更方便地计算🤗Huggingface平台模型的FLOPS。欢迎使用:https://huggingface.co/spaces/MrYXJ/calculate-model-flops
<img width="1480" alt="截屏2023-09-13 23 25 05" src="https://github.com/MrYxJ/calculate-flops.pytorch/assets/21152077/75b77665-9c72-49a9-a86c-0114da1945fd">对于大语言模型,这可能是最简单的FLOPs计算工具,对huggingface平台的模型非常方便。你可以使用calflops.calculate_flops_hf(model_name)
,通过huggingface模型中的model_name
来计算模型FLOPs,而无需在本地下载整个模型权重。注意,这种方法要求模型支持在meta设备上创建空模型进行推理。
from calflops import calculate_flops_hf model_name = "meta-llama/Llama-2-7b" access_token = "..." # 用于使用llama2的访问令牌 flops, macs, params = calculate_flops_hf(model_name=model_name, access_token=access_token) # 默认输入形状:(1, 128) print("%s FLOPs:%s MACs:%s Params:%s \n" %(model_name, flops, macs, params))
如果模型无法在meta设备上推理,你只需要将大语言模型对应的tokenizer分配给参数transformers_tokenizer
并传入calflops.calculate_flops()
函数,它将自动帮你构建大小为input_shape的模型输入数据。或者,你也可以传入你自己构建的需要多个数据输入的模型输入数据。
此外,这个包的实现过程受到了ptflops、deepspeed、hf accelerate库的启发,感谢他们的杰出工作,这些都是非常优秀的项目。同时,这个包也在它们的基础上改进了一些方面来计算FLOPs。
pip install --upgrade calflops
你也可以从https://pypi.org/project/calflops/下载最新的`calflops-*-py3-none-any.whl`文件
pip install calflops-*-py3-none-any.whl
如果模型只有一个输入,你只需要通过参数input_shape
设置模型输入大小,它可以自动生成随机模型输入来完成计算:
from calflops import calculate_flops from torchvision import models model = models.alexnet() batch_size = 1 input_shape = (batch_size, 3, 224, 224) flops, macs, params = calculate_flops(model=model, input_shape=input_shape, output_as_string=True, output_precision=4) print("Alexnet FLOPs:%s MACs:%s Params:%s \n" %(flops, macs, params)) #Alexnet FLOPs:4.2892 GFLOPS MACs:2.1426 GMACs Params:61.1008 M
如果模型有多个输入,请使用参数args
或kargs
,如下面的Transformer模型所示。
无需将整个模型参数权重下载到本地,只需通过模型名称就可以测试huggingface平台上的任何开源大模型。
from calflops import calculate_flops_hf batch_size, max_seq_length = 1, 128 model_name = "baichuan-inc/Baichuan-13B-Chat" flops, macs, params = calculate_flops_hf(model_name=model_name, input_shape=(batch_size, max_seq_length)) print("%s FLOPs:%s MACs:%s Params:%s \n" %(model_name, flops, macs, params))
你也可以使用huggingface平台的这个模型链接来计算其FLOPs。
from calflops import calculate_flops_hf batch_size, max_seq_length = 1, 128 model_name = "https://huggingface.co/THUDM/glm-4-9b-chat" # THUDM/glm-4-9b-chat flops, macs, params = calculate_flops_hf(model_name=model_name, input_shape=(batch_size, max_seq_length)) print("%s FLOPs:%s MACs:%s Params:%s \n" %(model_name, flops, macs, params))
------------------------------------- 计算Flops结果 -------------------------------------
符号说明:
参数数量(Params),乘加运算次数(MACs),
浮点运算次数(FLOPs),每秒浮点运算次数(FLOPS),
前向FLOPs(模型前向传播FLOPs),反向FLOPs(模型反向传播FLOPs),
默认模型反向传播计算量是前向传播的2.00倍。
总训练参数: 9.4 B
前向MACs: 1.12 TMACs
前向FLOPs: 2.25 TFLOPS
前向+反向MACs: 3.37 TMACs
前向+反向FLOPs: 6.74 TFLOPS
-------------------------------- 详细计算FLOPs结果 --------------------------------
每个模块计算结果按以下顺序列出:
参数,总参数百分比,MACs,总MACs百分比,FLOPS,总FLOPs百分比
注意:1. 一个模块可以有torch.nn.module或torch.nn.functional来计算logits(例如CrossEntropyLoss)。
它们在calflops中不被计为子模块,也不会被打印出来。但它们构成了父模块的MACs与其子模块总和之间的差异。
2. 浮点运算次数是理论估计,因此使用它计算的FLOPS可能大于系统最大吞吐量。
ChatGLMForConditionalGeneration(
94亿参数 = 100%参数,1.12万亿MACs = 100% MACs,2.25万亿FLOPS = 50% FLOPs
(transformer): ChatGLMModel(
94亿参数 = 100%参数,1.12万亿MACs = 100% MACs,2.25万亿FLOPS = 50% FLOPs
(embedding): Embedding(
6.2076亿参数 = 6.6%参数,0 MACs = 0% MACs,0 FLOPS = 0% FLOPs
(word_embeddings): Embedding(6.2076亿参数 = 6.6%参数,0 MACs = 0% MACs,0 FLOPS = 0% FLOPs,151552,4096)
)
(rotary_pos_emb): RotaryEmbedding(0 = 0%参数,0 MACs = 0% MACs,0 FLOPS = 0% FLOPs)
(encoder): GLMTransformer(
81.6亿参数 = 86.79%参数,1.04万亿MACs = 92.93% MACs,2.09万亿FLOPS = 46.46% FLOPs
(layers): ModuleList(
(0-39): 40 x GLMBlock(
2.0396亿参数 = 2.17%参数,26.11亿MACs = 2.32% MACs,52.21亿FLOPS = 1.16% FLOPs
(input_layernorm): RMSNorm(4100参数 = 0%参数,0 MACs = 0% MACs,0 FLOPS = 0% FLOPs)
(self_attention): SelfAttention(
3566万参数 = 0.38%参数,4.56亿MACs = 0.41% MACs,9.13亿FLOPS = 0.2% FLOPs
(query_key_value): Linear(1888万参数 = 0.2%参数,2.42亿MACs = 0.22% MACs,4.83亿FLOPS = 0.11% FLOPs,in_features=4096,out_features=4608,bias=True)
(core_attention): CoreAttention(
0 = 0%参数,0 MACs = 0% MACs,0 FLOPS = 0% FLOPs
(attention_dropout): Dropout(0 = 0%参数,0 MACs = 0% MACs,0 FLOPS = 0% FLOPs,p=0.0,inplace=False)
)
(dense): Linear(1678万参数 = 0.18%参数,2.15亿MACs = 0.19% MACs,4.29亿FLOPS = 0.1% FLOPs,in_features=4096,out_features=4096,bias=False)
)
(post_attention_layernorm): RMSNorm(4100参数 = 0%参数,0 MACs = 0% MACs,0 FLOPS = 0% FLOPs)
(mlp): MLP(
1.683亿参数 = 1.79%参数,21.54亿MACs = 1.92% MACs,43.09亿FLOPS = 0.96% FLOPs
(dense_h_to_4h): Linear(1.122亿参数 = 1.19%参数,14.36亿MACs = 1.28% MACs,28.72亿FLOPS = 0.64% FLOPs,in_features=4096,out_features=27392,bias=False)
(dense_4h_to_h): Linear(5610万参数 = 0.6%参数,7.18亿MACs = 0.64% MACs,14.36亿FLOPS = 0.32% FLOPs,in_features=13696,out_features=4096,bias=False)
)
)
)
(final_layernorm): RMSNorm(4100参数 = 0%参数,0 MACs = 0% MACs,0 FLOPS = 0% FLOPs)
)
(output_layer): Linear(6.2076亿参数 = 6.6%参数,79.46亿MACs = 7.07% MACs,158.91亿FLOPS = 3.54% FLOPs,in_features=4096,out_features=151552,bias=False)
)
)
有些模型使用需要先申请,你只需要通过access_token传入申请后的令牌即可计算其FLOPs。
[图片]
from calflops import calculate_flops_hf
batch_size, max_seq_length = 1, 128
model_name = "meta-llama/Llama-2-7b"
access_token = "" # 你使用llama2的申请令牌
flops, macs, params = calculate_flops_hf(model_name=model_name,
access_token=access_token,
input_shape=(batch_size, max_seq_length))
print("%s FLOPs:%s MACs:%s Params:%s \n" %(model_name, flops, macs, params))
### Transformer模型(本地)
与CNN模型相比,如果你想使用input_shape参数让calflops自动生成输入数据,Transformer模型应该通过transformer_tokenizer参数传入相应的分词器。
# Transformers模型,如bert。
from calflops import calculate_flops
from transformers import AutoModel
from transformers import AutoTokenizer
batch_size, max_seq_length = 1, 128
model_name = "hfl/chinese-roberta-wwm-ext/"
model_save = "../pretrain_models/" + model_name
model = AutoModel.from_pretrained(model_save)
tokenizer = AutoTokenizer.from_pretrained(model_save)
flops, macs, params = calculate_flops(model=model,
input_shape=(batch_size,max_seq_length),
transformer_tokenizer=tokenizer)
print("Bert(hfl/chinese-roberta-wwm-ext) FLOPs:%s MACs:%s Params:%s \n" %(flops, macs, params))
#Bert(hfl/chinese-roberta-wwm-ext) FLOPs:67.1 GFLOPS MACs:33.52 GMACs Params:102.27 M
如果你想使用自己生成的特定数据来计算FLOPs,可以使用args或kwargs参数,这种情况下input_shape参数不能再被赋值传入。以下是一个例子,可以看出相比使用transformer_tokenizer参数,这种方式不太方便。
# Transformers模型,如bert。
from calflops import calculate_flops
from transformers import AutoModel
from transformers import AutoTokenizer
batch_size, max_seq_length = 1, 128
model_name = "hfl/chinese-roberta-wwm-ext/"
model_save = "/code/yexiaoju/generate_tags/models/pretrain_models/" + model_name
model = AutoModel.from_pretrained(model_save)
tokenizer = AutoTokenizer.from_pretrained(model_save)
text = ""
inputs = tokenizer(text,
add_special_tokens=True,
return_attention_mask=True,
padding=True,
truncation="longest_first",
max_length=max_seq_length)
if len(inputs["input_ids"]) < max_seq_length:
apply_num = max_seq_length-len(inputs["input_ids"])
inputs["input_ids"].extend([0]*apply_num)
inputs["token_type_ids"].extend([0]*apply_num)
inputs["attention_mask"].extend([0]*apply_num)
inputs["input_ids"] = torch.tensor([inputs["input_ids"]])
inputs["token_type_ids"] = torch.tensor([inputs["token_type_ids"]])
inputs["attention_mask"] = torch.tensor([inputs["attention_mask"]])
flops, macs, params = calculate_flops(model=model,
kwargs = inputs,
print_results=False)
print("Bert(hfl/chinese-roberta-wwm-ext) FLOPs:%s MACs:%s Params:%s \n" %(flops, macs, params))
#Bert(hfl/chinese-roberta-wwm-ext) FLOPs:22.36 GFLOPS MACs:11.17 GMACs Params:102.27 M
from calflops import calculate_flops_hf batch_size, max_seq_length = 1, 128 model_name = "meta-llama/Llama-2-7b" access_token = "" # 使用llama的应用程序访问令牌 flops, macs, params = calculate_flops_hf(model_name=model_name, access_token=access_token, input_shape=(batch_size, max_seq_length)) print("%s FLOPs:%s MACs:%s Params:%s \n" %(model_name, flops, macs, params))
注意这里tokenizer必须与llm模型对应,因为llm tokenizer的处理过程可能不同。
#大型语言模型,如llama2-7b。 from calflops import calculate_flops from transformers import LlamaTokenizer from transformers import LlamaForCausalLM batch_size, max_seq_length = 1, 128 model_name = "llama2_hf_7B" model_save = "../model/" + model_name model = LlamaForCausalLM.from_pretrained(model_save) tokenizer = LlamaTokenizer.from_pretrained(model_save) flops, macs, params = calculate_flops(model=model, input_shape=(batch_size, max_seq_length), transformer_tokenizer=tokenizer) print("Llama2(7B) FLOPs:%s MACs:%s Params:%s \n" %(flops, macs, params)) #Llama2(7B) FLOPs:1.7 TFLOPS MACs:850.00 GMACs Params:6.74 B
calflops提供了更详细的模型FLOPs计算信息显示。通过设置参数print_result=True
(默认为True),模型的flops将在终端或jupyter界面打印出来。
同时,通过设置参数print_detailed=True
(默认为True),calflops支持显示整个模型中每个子模块的FLOPs、MACs和参数的计算结果和比例,方便查看整个模型中计算消耗最大的部分。
此外,参数compute_bp_factor用于确定反向传播的计算量是前向传播的多少倍。默认为2.0,根据https://epochai.org/blog/backward-forward-FLOP-ratio
</details> <details> <summary> 如何仅计算模型部分模块的FLOPs </summary> 您可以使用参数ignore_modules来选择在FLOPs计算过程中忽略模型的哪些模块。默认为[],即所有模型模块都会参与计算结果。 </details> <details> <summary> 如何计算LLM中generate函数的FLOPs </summary> 您只需要将"generate"赋值给参数forward_mode即可。 </details></details> <details> <summary> calflops.calculate_flops_hf() </summary>from calflops import calculate_flops def calculate_flops(model, input_shape=None, transformer_tokenizer=None, args=[], kwargs={}, forward_mode="forward", include_backPropagation=False, compute_bp_factor=2.0, print_results=True, print_detailed=True, output_as_string=True, output_precision=2, output_unit=None, ignore_modules=None): """返回模型的总浮点运算次数、MACs和参数数量。 参数: model ([torch.nn.Module]): 输入的模型必须是PyTorch模型。 input_shape (tuple, 可选): 模型的输入形状。如果args和kwargs为空,则模型将以此形状的张量作为唯一的位置参数。默认为[]。 transformers_tokenizer (None, 可选): 如果模型类型是transformers且args、kwargs为空,则必须指定Transformers Tokenizer。默认为None。 args (list, 可选): 模型的位置参数列表,例如bert输入参数为[input_ids, token_type_ids, attention_mask]。默认为[]。 kwargs (dict, 可选): 模型的关键字参数字典,例如bert输入kwargs为{'input_ids': ..., 'token_type_ids':..., 'attention_mask':...}。默认为{}。 forward_mode (str, 可选): 确定模型推理的模式,默认为'forward'。如果模型推理使用model.generate(),则使用'generate'。 include_backPropagation (bool, 可选): 决定最终返回的FLOPs计算是否包括反向传播的计算。 compute_bp_factor (float, 可选): 模型反向传播是前向传播计算的倍数。默认为2。 print_results (bool, 可选): 是否打印模型概况。默认为True。 print_detailed (bool, 可选): 是否打印详细的模型概况。默认为True。 output_as_string (bool, 可选): 是否将输出打印为字符串。默认为True。 output_precision (int, 可选): 如果output_as_string为True,则输出保留的小数位数。默认为2。 output_unit (str, 可选): 用于输出结果值的单位,如T、G、M和K。默认为None,即输出单位由值决定。 ignore_modules ([type], 可选): 在分析过程中要忽略的模块列表。默认为None。
def calculate_flops_hf(model_name, input_shape=None, library_name="transformers", trust_remote_code=True, access_token="", forward_mode="forward", include_backPropagation=False, compute_bp_factor=2.0, print_results=True, print_detailed=True, output_as_string=True, output_precision=2, output_unit=None, ignore_modules=None): """返回模型的总浮点运算次数、MACs和参数数量。 参数: model_name (str):Hugging Face平台上的模型名称 https://huggingface.co/models,如meta-llama/Llama-2-7b、baichuan-inc/Baichuan-13B-Chat等。 input_shape (tuple, 可选):模型的输入形状。如果args和kwargs为空,模型将以此形状的张量作为唯一的位置参数。默认为[]。 trust_remote_code (bool, 可选):是否信任远程库中的模型结构代码。 access_token (str, 可选):某些模型需要申请访问令牌,如meta llama2等。 forward_mode (str, 可选):确定模型推理的模式,默认为'forward'。如果模型推理使用model.generate(),则使用'generate'。 include_backPropagation (bool, 可选):决定最终返回的FLOPs计算是否包括反向传播的计算。 compute_bp_factor (float, 可选):模型反向传播是前向传播计算的倍数。默认为2。 print_results (bool, 可选):是否打印模型概况。默认为True。 print_detailed (bool, 可选):是否打印详细的模型概况。默认为True。 output_as_string (bool, 可选):是否将输出打印为字符串。默认为True。 output_precision (int, 可选):如果output_as_string为True,输出保留的小数位数。默认为2。 output_unit (str, 可选):用于输出结果值的单位,如T、G、M和K。默认为None,即输出单位根据值决定。 ignore_modules ([type], 可选):在分析过程中要忽略的模块列表。默认为None。 示例: .. code-block:: python from calflops import calculate_flops_hf batch_size = 1 max_seq_length = 128 model_name = "baichuan-inc/Baichuan-13B-Chat" flops, macs, params = calculate_flops_hf(model_name=model_name, input_shape=(batch_size, max_seq_length)) print("%s FLOPs:%s MACs:%s Params:%s \n" %(model_name, flops, macs, params)) 返回: 模型的浮点运算次数、乘加运算次数(MACs)和参数数量。
def generate_transformer_input(model_tokenizer, input_shape, device): """自动生成transformer模型输入格式的数据。
参数:
input_shape (tuple):transformers模型输入形状:(batch_size, seq_len)。
tokenizer (transformer.model.tokenization):transformers模型的tokenization.tokenizer。
返回:
dict:transformers模型输入的数据格式,是一个包含'input_ids'、'attention_mask'、'token_type_ids'等的字典。
"""
## 常见模型FLOPs计算
### 大型语言模型
输入数据格式:batch_size=1, seq_len=128
- fwd FLOPs:模型前向传播的FLOPs
- bwd + fwd FLOPs:模型前向和反向传播的FLOPs
此外,请注意fwd + bwd不包括模型参数激活重计算的损失计算,如果结果想包括激活重计算,只需将fwd FLOPs的结果乘以4即可(根据论文:https://arxiv.org/pdf/2205.05198.pdf),在calflops中,你可以轻松设置参数```computer_bp_factor=3```来使结果包括激活重计算。
模型 | 输入形状 | 参数量(B) | 总参数量 | 前向FLOPs(G) | 前向MACs(G) | 前向+反向FLOPs(G) | 前向+反向MACs(G) |
--- |--- |--- |--- |--- |--- |--- |---
bloom-1b7 |(1,128) | 1.72B | 1722408960 | 310.92 | 155.42 | 932.76 | 466.27
bloom-7b1 |(1,128) | 7.07B | 7069016064 | 1550.39 | 775.11 | 4651.18 | 2325.32
bloomz-1b7 |(1,128) | 1.72B | 1722408960 | 310.92 | 155.42 | 932.76 | 466.27
baichuan-7B |(1,128) | 7B | 7000559616 | 1733.62 | 866.78 | 5200.85 | 2600.33
chatglm-6b |(1,128) | 6.17B | 6173286400 | 1587.66 | 793.75 | 4762.97 | 2381.24
chatglm2-6b |(1,128) | 6.24B | 6243584000 | 1537.68 | 768.8 | 4613.03 | 2306.4
Qwen-7B |(1,128) | 7.72B | 7721324544 | 1825.83 | 912.88 | 5477.48 | 2738.65
llama-7b |(1,128) | 6.74B | 6738415616 | 1700.06 | 850 | 5100.19 | 2550
llama2-7b |(1,128) | 6.74B | 6738415616 | 1700.06 | 850 | 5100.19 | 2550
llama2-7b-chat |(1,128) | 6.74B | 6738415616 | 1700.06 | 850 | 5100.19 | 2550
chinese-llama-7b | (1,128) | 6.89B | 6885486592 | 1718.89 | 859.41 |5156.67 | 2578.24
chinese-llama-plus-7b| (1,128) | 6.89B | 6885486592 | 1718.89 | 859.41 |5156.67 | 2578.24
EleutherAI/pythia-1.4b | (1,128) | 1.31B | 1311625216 | 312.54 | 156.23 |937.61 | 468.69
EleutherAI/pythia-12b | (1,128) | 11.59B | 11586549760 | 2911.47 | 1455.59 | 8734,41 | 4366.77
moss-moon-003-sft |(1,128) | 16.72B | 16717980160 | 4124.93 | 2062.39 | 12374.8 | 6187.17
moss-moon-003-sft-plugin |(1,128) | 16.06B | 16060416000 | 3956.62 | 1978.24 | 11869.9 | 5934.71
从上表中我们可以得出一些简单有趣的结论:
- 在相同规模的模型中,chatglm2-6b的模型参数更小,FLOPs也更小,在速度性能方面有一定优势。
- llama1-7b、llama2-7b和llama2-7b-chat模型的参数完全没有变化,FLOPs保持一致。符合meta在其llama2报告中描述的7b模型结构没有改变,主要区别在于增加了训练数据量。
- 同样,从表中可以看出,chinese-llama-7b和chinese-llama-plus-7b的数据也符合cui的报告,只是增加了更多中文数据进行训练,模型结构和参数没有改变。
- ......
更多模型的FLOPs将陆续更新,请参见GitHub [calculate-flops.pytorch](https://github.com/MrYxJ/calculate-flops.pytorch)
### Bert
输入数据格式:batch_size=1,seq_len=128
模型 | 输入形状 | 参数量(M) | 总参数量 | 前向FLOPs(G) | 前向MACs(G) | 前向+后向FLOPs(G) | 前向+后向MACs(G)
--- | --- | --- | --- | --- | --- | --- | ---
hfl/chinese-roberta-wwm-ext | (1,128) | 102.27M | 102267648 | 22.363 | 11.174 | 67.089 | 33.523
......
你可以使用calflops来计算更多基于bert的不同transformer模型,期待在此表格中更新。
## 基准测试
### [torchvision](https://pytorch.org/docs/1.0.0/torchvision/models.html)
输入数据格式:batch_size = 1,实际输入形状 = (1, 3, 224, 224)
注意:表中的FLOPs仅考虑了模型前向传播的计算,**Total**指不带单位缩写的总数值表示。
模型 | 输入分辨率 | 参数量(M) | 总参数量 | FLOPs(G) | 总FLOPs | Macs(G) | 总Macs
--- | --- | --- | --- | --- | --- | --- | ---
alexnet | 224x224 | 61.10 | 61100840 | 1.43 | 1429740000 | 741.19 | 7418800000
vgg11 | 224x224 | 132.86 | 132863000 | 15.24 | 15239200000 | 7.61 | 7609090000
vgg13 | 224x224 | 133.05 | 133048000 | 22.65 | 22647600000 | 11.31 | 11308500000
vgg16 | 224x224 | 138.36 | 138358000 | 30.97 | 30973800000 | 15.47 | 15470300000
vgg19 | 224x224 | 143.67 | 143667000 | 39.30 | 39300000000 | 19.63 | 19632100000
vgg11_bn | 224x224 | 132.87 | 132869000 | 15.25 | 15254000000 | 7.61 | 7609090000
vgg13_bn | 224x224 | 133.05 | 133054000 | 22.67 | 22672100000 | 11.31 | 11308500000
vgg16_bn | 224x224 | 138.37 | 138366000 | 31.00 | 31000900000 | 15.47 | 15470300000
vgg19_bn | 224x224 | 143.68 | 143678000 | 39.33 | 39329700000 | 19.63 | 19632100000
resnet18 | 224x224 | 11.69 | 11689500 | 3.64 | 3636250000 | 1.81 | 1814070000
resnet34 | 224x224 | 21.80 | 21797700 | 7.34 | 7339390000 | 3.66 | 3663760000
resnet50 | 224x224 | 25.56 | 25557000 | 8.21 | 8211110000 | 4.09 | 4089180000
resnet101 | 224x224 | 44.55 | 44549200 | 15.65 | 15690900000 | 7.80 | 7801410000
resnet152 | 224x224 | 60.19 | 60192800 | 23.09 | 23094300000 | 11.51 | 11513600000
squeezenet1_0 | 224x224 | 1.25 | 1248420 | 1.65 | 1648970000 | 0.82 | 818925000
squeezenet1_1 | 224x224 | 1.24 | 1235500 | 0.71 | 705014000 | 0.35 | 349152000
densenet121 | 224x224 | 7.98 | 7978860 | 5.72 | 5716880000 | 2.83 | 2834160000
densenet169 | 224x224 | 14.15 | 14195000 | 6.78 | 6778370000 | 3.36 | 3359840000
densenet201 | 224x224 | 20.01 | 20013900 | 8.66 | 8658520000 | 4.29 | 4291370000
densenet161 | 224x224 | 28.68 | 28681000 | 15.55 | 1554650000 | 7.73 | 7727900000
inception_v3 | 224x224 | 27.16 | 27161300 | 5.29 | 5692390000 | 2.84 | 2837920000
感谢@[zigangzhao-ai](https://github.com/zigangzhao-ai)使用```calflops```统计torchvision表格。
你也可以将torchvision的FLOPs计算结果与另一个优秀工具进行比较:[ptflops readme.md](https://github.com/sovrasov/flops-counter.pytorch/)。
## 联系作者
作者:[MrYXJ](https://github.com/MrYxJ/)
邮箱:yxj2017@gmail.com
一键生成PPT和Word,让学习生活更轻松
讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。
深度推理能力全新升级,全面对标OpenAI o1
科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多 功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。
一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型
Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。
字节跳动发布的AI编程神器IDE
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。
AI助力,做PPT更简单!
咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。
选题、配图、成文,一站式创作,让内容运营更高效
讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加 速品牌传播,提升内容营销效果。
专业的AI公文写作平台,公文写作神器
AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。
OpenAI Agents SDK,助力开发者便捷使用 OpenAI 相关功能。
openai-agents-python 是 OpenAI 推出的一款强大 Python SDK,它为开发者提供了与 OpenAI 模型交互的高效工具,支持工具调用、结果处理、追踪等功能,涵盖多种应用场景,如研究助手、财务研究等,能显著提升开发效率,让开发者更轻松地利用 OpenAI 的技术优势。
高分辨率纹理 3D 资产生成
Hunyuan3D-2 是腾讯开发的用于 3D 资产生成的强大工具,支持从文本描述、单张图片或多视角图片生成 3D 模型,具备快速形状生成能力,可生成带纹理的高质量 3D 模型,适用于多个领域,为 3D 创作提供了高效解决方案。
一个具备存储、管理和客户端操作等多种功能的分布式文件系统相关项目。
3FS 是一个功能强大的分布式文件系统项目,涵盖了存储引擎、元数据管理、客户端工具等多个模块。它支持多种文件操作,如创建文件和目录、设置布局等,同时具备高效的事件循环、节点选择和协程池管理等特性。适用于需要大规模数据存储和管理的场景,能够提高系统的性能和可靠性,是分布式存储领域的优质解决方案。
最新AI工具、AI资讯
独家AI资源、AI项目落地
微信扫一扫关注公众号