使用MindSpore查看模型参数

时间:2026-02-13 20:19:04

1、可以直接加载CheckPoint统计,可能额外统计了动量和optimizer中的变量,需要过滤下相关变量。 可以参考如下接口统计网络参数量。

def count_params(net):

    """Count number of parameters in the network

    Args:

        net (mindspore.nn.Cell): Mindspore network instance

    Returns:

        total_params (int): Total number of trainable params

    """

    total_params = 0

    for param in net.trainable_params():

        total_params += np.prod(param.shape)

    return total_params

© 2026 五度知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com