def size_num_grads(link):
    'Count total size of all gradient arrays of a given link\n\n    Args:\n        link (chainer.link.Link): Target link object.\n    '
    size = 0
    num = 0
    for param in link.params():
        if (param.size == 0):
            continue
        size += param.size
        num += 1
    return (size, num)
Count total size of all gradient arrays of a given link

Args:
    link (chainer.link.Link): Target link object.
def size_num_grads(link):
    'Count total size of all gradient arrays of a given link\n\n    Args:\n        link (chainer.link.Link): Target link object.\n    '
    size = 0
    num = 0
    for param in link.params():
        if (param.size == 0):
            continue
        size += param.size
        num += 1
    return (size, num)