Pytorch - Batch Normalizaiton simple question
I implemented a model with batch normalization:

class FFNet(torch.nn.Module):
    def __init__(self, D_in, H_1, H_2, D_out):

        super(FFNet, self).__init__()
        self.linear1 = torch.nn.Linear(D_in, H_1)
        self.linear2 = torch.nn.Linear(H_1, H_2)
        self.bn2 = torch.nn.BatchNorm1d(H_2)
        self.linear4 = torch.nn.Linear(H_2, D_out)

    def forward(self, x):

        h_relu_1=F.relu(self.linear1(x))
        h_relu_2=F.relu(self.bn2(self.linear2(h_relu_1)))
        y_pred=self.linear4(h_relu_2)
        return y_pred


Also, I wrote the training loop:

for epoch in range(epoches):

    running_loss = 0.0
    cnt = 0
    for i, data in enumerate(train_data, 0):
        local_X, local_y = data
        y_pred = model.forward(local_X)
        loss = criterion(y_pred, local_y)
        optimizer.zero_grad()
        #loss = criterion(y_pred, Y_local_output)
        loss.backward() # back props
        optimizer.step()
        running_loss = running_loss + loss.item()
        cnt+=1


    Validation_loss = 0.0
    cnt2 = 0
    # Validation
    for i, data in enumerate(validation_data, 0):
        Val_X, Val_Y = data

        y_pred = model.forward(Val_X)

        loss=criterion(y_pred, Val_Y)
        Validation_loss = Validation_loss + loss.item()
        cnt2+=1


I have two questions:
1. Is there no need to use model.train() in this code?
2. How to evaluate this model using eval? I have one data sample whose size is (1xD_in), and batch size is more than 1. When I use the below code, there is an error:

    test_single = torch.tensor([aa, ab, ac, ad, ae, af, ag])
    test_single = test_single.unsqueeze(0)

    model.eval()
    [bb,cc] = model.forward(test_single)



The error is 'not enough values to unpack (expected 2, got 1)'

If you have batch normalization, then you do need to use model.train() and model.eval() while training and evaluating respectively.

The 2nd part (the unsqueezing code) is not wrong. However, there is only one output of your model (see the return statement of your model's forward function), which causes the error i.e. you try to unpack 2 values whereas there is only one. So, you can't do 

[bb,cc] = model.forward(test_single)


You have to do 

out = model.forward(test_single)


I tried this and it works.
