Due to my CUDA version being 8, I am using torch 1.0.0
I need to use the Flatten layer for Sequential model. Here's my code :
import torch
import torch.nn as nn
import torch.nn.functional as F
print(torch.__version__)
# 1.0.0
from collections import OrderedDict
layers = OrderedDict()
layers['conv1'] = nn.Conv2d(1, 5, 3)
layers['relu1'] = nn.ReLU()
layers['conv2'] = nn.Conv2d(5, 1, 3)
layers['relu2'] = nn.ReLU()
layers['flatten'] = nn.Flatten()
layers['linear1'] = nn.Linear(3600, 1)
model = nn.Sequential(
layers
).cuda()
It gives me the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-38-080f7c5f5037> in <module>
6 layers['conv2'] = nn.Conv2d(5, 1, 3)
7 layers['relu2'] = nn.ReLU()
----> 8 layers['flatten'] = nn.Flatten()
9 layers['linear1'] = nn.Linear(3600, 1)
10 model = nn.Sequential(
AttributeError: module 'torch.nn' has no attribute 'Flatten'
How can I flatten my conv layer output in pytorch 1.0.0?