差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
人工智能:paddle:paddle常用脚本:paddle统计模型信息 [2026/01/09 08:37] – [打印paddle模型的基本信息] ctbots人工智能:paddle:paddle常用脚本:paddle统计模型信息 [2026/01/09 08:38] (当前版本) ctbots
行 18: 行 18:
 # print_paddle_model("xxx/model_state.pdparams") # print_paddle_model("xxx/model_state.pdparams")
 </code> </code>
 +
 +===== 打印paddle的模型的基本信息 =====
 +
 +假如我们已经加载了一个paddle的module模型信息,如何打印具体的参数信息。
 +
 +<code python p.py>
 +        state_dict = model.state_dict()
 +        for name, tensor in state_dict.items():
 +            dtype = getattr(tensor, "dtype", "<unknown>")
 +            shape = list(tensor.shape) if hasattr(tensor, "shape") else []
 +            numel = tensor.numel() if hasattr(tensor, "numel") else 0
 +            print(f"{name:60s} | dtype={dtype} | shape={shape} | numel={numel}")
 +</code>
 +
 +