How can I change the padded input size per channel in Pytorch?
I am trying to set up an image classifier using Pytorch. My sample images have 4 channels and are 28x28 pixels in size. I am trying to use the built-in torchvision.models.inception_v3() as my model. Whenever I try to run my code, I get this error: 


  RuntimeError: Calculated padded input size per channel: (1 x 1).
  Kernel size: (3 x 3). Kernel size can't greater than actual input size
  at
  /opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/THNN/generic/SpatialConvolutionMM.c:48


I can't find how to change the padded input size per channel or quite figure out what the error means. I figure that I must modify the padded input size per channel since I can't edit the Kernel size in the pre-made model.

I have tried padding, but it didn't help.
Here is a shortened part of my code that throws the error when I call train():

import torch
import torchvision as tv
import torch.optim as optim
from torch import nn
from torch.utils.data import DataLoader

model = tv.models.inception_v3()
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=0.0001, weight_decay=0)
lr_scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=4, gamma=0.9)  

trn_dataset = tv.datasets.ImageFolder(
    "D:/tests/classification_test_data/trn",
    transform=tv.transforms.Compose([tv.transforms.RandomRotation((0,275)), tv.transforms.RandomHorizontalFlip(),
                                  tv.transforms.ToTensor()]))
trn_dataloader = DataLoader(trn_dataset, batch_size=32, num_workers=4, shuffle=True)

for epoch in range(0, 10):
    train(trn_dataloader, model, criterion, optimizer, lr_scheduler, 6, 32)
print("End of training")


def train(train_loader, model, criterion, optimizer, scheduler, num_classes, batch_size):
    model.train()
    scheduler.step()

    for index, data in enumerate(train_loader):
        inputs, labels = data
        optimizer.zero_grad()
        outputs = model(inputs)
        outputs_flatten = flatten_outputs(outputs, num_classes)
        loss = criterion(outputs_flatten, labels)
        loss.backward()
        optimizer.step()


def flatten_outputs(predictions, number_of_classes):
    logits_permuted = predictions.permute(0, 2, 3, 1)
    logits_permuted_cont = logits_permuted.contiguous()
    outputs_flatten = logits_permuted_cont.view(-1, number_of_classes)
    return outputs_flatten


It could be due the following. Pytorch documentation for Inception_v3 model notes that the model expects input of shape Nx3x299x299. This is because the architecture contains a fully connected layer which fixed shape. 


  Important: In contrast to the other models the inception_v3 expects tensors with a size of N x 3 x 299 x 299, so ensure your images are sized accordingly.


https://pytorch.org/docs/stable/torchvision/models.html#inception-v3
