所以我有2DCNN模型来分类图像,只有2个类,每个类有300个图像。 这是我的nn模块类
class Flatten(Module):
def forward(self, input):
return input.view(input.size(0), -1)
class ActionNet(Module):
def __init__(self, num_class=4):
super(ActionNet, self).__init__()
self.cnn_layer = Sequential(
#conv1
Conv2d(in_channels=1, out_channels=32, kernel_size=1, bias=False),
BatchNorm2d(32),
PReLU(num_parameters=32),
MaxPool2d(kernel_size=3),
#conv2
Conv2d(in_channels=32, out_channels=64, kernel_size=1, bias=False),
BatchNorm2d(64),
PReLU(num_parameters=64),
MaxPool2d(kernel_size=3),
#flatten
Flatten(),
Linear(576, 128),
BatchNorm1d(128),
ReLU(inplace=True),
Dropout(0.5),
Linear(128, num_class)
)
def forward(self, x):
x = self.cnn_layer(x)
return x
我将培训和测试分为80%:20%,以了解更多详细信息,这里是我的培训代码:https://pastebin.com/uzBFTrDc,当我尝试使用colab进行培训时,出现了一个错误:
RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 15.90 GiB total capacity; 15.20 GiB already allocated; 1.88 MiB free; 15.20 GiB reserved in total by PyTorch)
我使用谷歌colab是因为我没有强大的GPU和实现批处理,我不知道它是否正确,训练数据只有400个大小为32x32的图像,我认为colab足够强大来训练我的数据
目前没有回答
相关问题 更多 >
编程相关推荐