(model)
return sum(map(lambda t: t[0]*t[1],sizes)), sum(map(lambda t: t[0]*(1 - t[1]),sizes))
Computes number of trainable and non-trainable parameters
Computes number of trainable and non-trainable parameters
Computes number of trainable and non - trainable parameters
def compute_num_params(model):
    """
    Computes number of trainable and non-trainable parameters
    """
    sizes = [(np.array(p.data.size()).prod(), int(p.requires_grad)) for p in model.parameters()]
    return sum(map(lambda t: t[0]*t[1],sizes)), sum(map(lambda t: t[0]*(1 - t[1]),sizes))
def compute_num_params ( model ) : sizes = [ ( np . array ( p . data . size ( ) ) . prod ( ) , int ( p . requires_grad ) ) for p in model . parameters ( ) ] return sum ( map ( lambda t : t [ 0 ] * t [ 1 ] , sizes ) ) , sum ( map ( lambda t : t [ 0 ] * ( 1 - t [ 1 ] ) , sizes ) )