epoch_end = epoch_start
    epoch_prev = epoch_start - 1
    assert epoch_prev >= 0

    # device
    use_gpu_if_available = True
    use_CUDA = use_gpu_if_available and torch.cuda.is_available()
    if use_CUDA:
        device = torch.device('cuda')
    else:
        device = torch.device('cpu')
    print('# using', device)

    # loading VGG11-bn pretrained model
    #vgg16 = torchvision.models.vgg16(pretrained=False)
    vgg16 = DCTnet.DCTnet2v2()
    print(vgg16)

    # loading the parameters
    fnParam_prev = f'data/ex20210103_trainDCT2v2_epoch{epoch_prev:03d}.pth'
    if epoch_prev != 0:
        with open(fnParam_prev, mode='rb') as f:
            vgg16.load_state_dict(torch.load(f))

    nn = vgg16.to(device)
    nn.train()

    # dataset & dataloader
    dL = ilsvrc2012.datasets('L')
    bsize = 256
    dl = torch.utils.data.DataLoader(dL,
Beispiel #2
0
import sys

import ilsvrc2012
import DCTnet

if __name__ == '__main__':

    if len(sys.argv) != 2:
        print(f'usage: {sys.argv[0]} epoch')
        exit()

    epoch = int(sys.argv[1])

    # loading VGG16 model
    #vgg16 = torchvision.models.vgg16(pretrained=False)
    vgg16 = DCTnet.DCTnet2()
    print(vgg16)

    # loading the parameters
    fnParam = f'data/ex20201228b_trainDCT2_epoch{epoch:03d}.pth'
    with open(fnParam, mode='rb') as f:
        vgg16.load_state_dict(torch.load(f))

    # device
    use_gpu_if_available = True
    use_CUDA = use_gpu_if_available and torch.cuda.is_available()
    if use_CUDA:
        device = torch.device('cuda')
    else:
        device = torch.device('cpu')
    print('# using', device)
Beispiel #3
0
import sys

import ilsvrc2012
import DCTnet

if __name__ == '__main__':

    if len(sys.argv) != 2:
        print(f'usage: {sys.argv[0]} epoch')
        exit()

    epoch = int(sys.argv[1])

    # loading VGG16 model
    #vgg16 = torchvision.models.vgg16(pretrained=False)
    vgg16 = DCTnet.DCTnet()
    print(vgg16)

    # loading the parameters
    fnParam = f'data/ex20201228_trainDCT_epoch{epoch:03d}.pth'
    with open(fnParam, mode='rb') as f:
        vgg16.load_state_dict(torch.load(f))

    # device
    use_gpu_if_available = True
    use_CUDA = use_gpu_if_available and torch.cuda.is_available()
    if use_CUDA:
        device = torch.device('cuda')
    else:
        device = torch.device('cpu')
    print('# using', device)
Beispiel #4
0
import ilsvrc2012
import DCTnet


if __name__ == '__main__':

    if len(sys.argv) != 2:
        print(f'usage: {sys.argv[0]} epoch')
        exit()

    epoch = int(sys.argv[1])

    # loading VGG16 model
    #vgg16 = torchvision.models.vgg16(pretrained=False)
    vgg16 = DCTnet.DCTnet3()
    print(vgg16)

    # loading the parameters
    fnParam = f'data/ex20201228c_trainDCT3_epoch{epoch:03d}.pth'
    with open(fnParam, mode='rb') as f:
        vgg16.load_state_dict(torch.load(f))

    # device
    use_gpu_if_available = True
    use_CUDA = use_gpu_if_available and torch.cuda.is_available()
    if use_CUDA:
        device = torch.device('cuda')
    else:
        device = torch.device('cpu')
    print('# using', device)