[Pytorch Error] RuntimeError: Given input size: (256x1x1). Calculated output size: (256x0x0). Output size is too small

2020. 1. 21. 16:58Develop

Issue

RuntimeError: Given input size: (256x1x1). Calculated output size: (256x0x0). Output size is too small

input tensor의 크기가 작아서 생기는 문제이다. input tensor의 shape을 조정해주면 해결 가능하다.

 

Solution

transform = transforms.Compose([
        transforms.Resize(256),
        transforms.RandomHorizontalFlip(),
        transforms.ToTensor(),
        transforms.Normalize(
            mean=model.original_model_info.mean,
            std=model.original_model_info.std
        ),
    ])

 

Reference