File size: 527 Bytes
e018a19
618a701
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Copyright (c) 2024, SliceX AI, Inc.


def count_parameters(model):
    """Count the number of parameters in the model."""
    total_params = 0

    for name, parameter in model.named_parameters():
        if not parameter.requires_grad: continue
        params = parameter.numel()
        total_params+=params
    
    print(f"Total Trainable Params: {total_params}")
    return total_params
    

def batchify(lst, n):
    """Divide a list into chunks of size n."""
    return [lst[i:i + n] for i in range(0, len(lst), n)]