File size: 680 Bytes
5032722
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun  3 15:59:45 2025

"""
import torch
import random
from torch.utils.data import DataLoader
import numpy as np

def init_dataloader(args, 
                    shuffle,
                    pytorch_custom_dset,
                    collate_fn):
    if shuffle:
        torch.manual_seed(args.rng_seednum)
        random.seed(args.rng_seednum)
        np.random.seed(args.rng_seednum)
        
    dl = DataLoader( pytorch_custom_dset, 
                     batch_size = args.batch_size, 
                     shuffle = shuffle,
                     collate_fn = collate_fn
                     )
    
    return dl