I am seeing an error in the code for detecting objetcs in a video?

class tinyvgg12(nn.Module):
def init(self,input,hidden,output):
super().init()
self.Conv_block1 = nn.Sequential(
nn.Conv2d(
in_channels = input,
out_channels = hidden,
kernel_size=3,
stride=1,
padding=1
),
nn.ReLU(),
nn.Conv2d(
in_channels = hidden,
out_channels = hidden,
kernel_size=3,
stride=1,
padding=1
),
nn.ReLU(),
nn.MaxPool2d(kernel_size=2,stride=2)
)

self.Conv_block2 = nn.Sequential(
    nn.Conv2d(
        in_channels =hidden,
        out_channels = hidden,
        kernel_size=3,
        stride=1,
        padding=1
    ),
    nn.ReLU(),
    nn.Conv2d(
        in_channels=hidden,
        out_channels=hidden,
        kernel_size=3,
        stride=1,
        padding=1
    ),
    nn.ReLU(),
    nn.MaxPool2d(kernel_size=2,stride=2)
)

self.classifier = nn.Sequential(
    nn.Flatten(),
    nn.Linear(
        in_features=hidden*16*16,
        out_features=output
    )
)
self.avgpool = nn.AdaptiveAvgPool2d((3,3))

def forward(self,x):
x = self.Conv_block1(x)
#print(x.shape)
x = self.Conv_block2(x)
#print(x.shape)
x = self.classifier(x)
#print(x.shape)
x = self.avgpool(x)
return x
return self.Conv_block2(self.Conv_block1(x)) i put adaptive pooling but i still seeing the error :----------------------------------------------------------------------------
ValueError Traceback (most recent call last)
in <cell line: 9>()
8
9 for epoch in tqdm(range(epochs)):
—> 10 train_step(model=model_x_5.to(device),
11 data_loader=train_dataloader,
12 optimizer=optimizer,

6 frames
/usr/local/lib/python3.10/dist-packages/torch/nn/modules/utils.py in _list_with_default(out_size, defaults)
35 return out_size
36 if len(defaults) <= len(out_size):
—> 37 raise ValueError(
38 “Input dimension should be at least {}”.format(len(out_size) + 1)
39 )

ValueError: Input dimension should be at least 3

You posted this in the General Discussion category. Please move it to the relevant course category with the week and assignment number. Check this on how to change the category.

You still didn’t mention which week and assignment number it is in DLS Course 4.

i am not in a course , i am a random person asking a doubt

If this is not a course-related question, then posting it in a DLS course category is not a good idea.

Regarding your error, the problem is with your input data. It should be at least 3D for a convolutional neural network.

@saifkhanengr you mean i need to change to MaxPool3d ?

No. What is the shape of your input data?