hello, i want to make mcldnn model in this git hub : https://github.com/wzjialang/MCLDNN/blob/master/MCLDNN.py
but the same model I made is not train without batch norm and even though use batch norm, accuracy is decrease
this is my mcldnn model:
sequence_length = 1
input_size = 124
hidden_size = 124
num_layers = 1
num_classes = 11
batch = 400
num_epochs = 2
learning_rate = 0.001
drop = 0.6
class RNN(nn.Module):
def init(self, input_size, hidden_size, num_layers, num_classes):
super(RNN, self).init() #
self.conv1 = nn.Conv2d(1,50,(2,8))
self.conv2 = nn.Conv1d(1,50,8)
self.conv3 = nn.Conv1d(1,50,8)
self.conv4 = nn.Conv2d(50,50,(2,8))
self.conv5 = nn.Conv2d(100,100,(2,5))
self.bn1 = nn.BatchNorm2d(50)
self.bn2 = nn.BatchNorm1d(50)
self.bn3 = nn.BatchNorm1d(50)
self.bn4 = nn.BatchNorm2d(50)
self.bn5 = nn.BatchNorm2d(100)
self.drop1 = nn.Dropout(drop)
self.drop2 = nn.Dropout(drop)
self.drop3 = nn.Dropout(drop)
self.drop4 = nn.Dropout(drop)
self.drop5 = nn.Dropout(drop)
self.hidden_size = hidden_size
self.num_layers = num_layers
self.lstm1 = nn.LSTM(input_size, hidden_size, num_layers,bidirectional=False, batch_first=True)
self.relu5 = nn.ReLU()
self.lstm2 = nn.LSTM(124, hidden_size, num_layers,bidirectional=False, batch_first=True)
self.fc1 = nn.Linear(124,128)
self.fc2 = nn.Linear(128,128)
self.fc3 = nn.Linear(128,11)
def forward(self, x):
input_ = torch.reshape(x,(x.size(0),1,x.size(1),x.size(2)))
input_I = input_[:,:,0,:]
input_Q = input_[:,:,1,:]
input_I = torch.reshape(input_I,(x.size(0),1,x.size(2)))
input_Q = torch.reshape(input_Q,(x.size(0),1,x.size(2)))
input_ = F.pad(input_, (0,7,0,1))
x1 = self.conv1(input_)
x1 = self.bn1(x1)
x1 = F.relu(x1)
x1 = self.drop1(x1)
input_I = F.pad(input_I, (0,7))
x2 = self.conv2(input_I)
x2 = self.bn2(x2)
x2 = F.relu(x2)
x2 = self.drop2(x2)
input_Q = F.pad(input_Q, (0,7))
x3 = self.conv3(input_Q)
x3 = self.bn3(x3)
x3 = F.relu(x3)
x3 = self.drop3(x3)
x2 = torch.reshape(x2,(x2.size(0),x2.size(1),1,x2.size(2)))
x3 = torch.reshape(x3,(x3.size(0),x3.size(1),1,x3.size(2)))
cat1 = torch.cat((x2,x3),2)
cat1 = F.pad(cat1, (0,7,0,1))
cat1 = self.conv4(cat1)
cat1 = self.bn4(cat1)
cat1 = F.relu(cat1)
cat1 = self.drop4(cat1)
cat2 = torch.cat((cat1,x1),1)
cat2 = F.pad(cat2, (4,0))
cat2 = self.conv5(cat2)
cat2 = self.bn5(cat2)
cat2 = F.relu(cat2)
cat2 = self.drop5(cat2)
cat2 = torch.reshape(cat2,(cat2.size(0),cat2.size(1),cat2.size(3)))
out, _ = self.lstm1(cat2)
out, _ = self.lstm1(out)
out = out[:,-1,:]
out = self.fc1(out)
out = F.relu(out)
out = self.fc2(out)
out = F.relu(out)
out = self.fc3(out)
return out