i’m trying to get my validation to work within my training model
Currently
def train(epoch):
    model.train()
    correct = 0
    train_loss = 0
    vloss = 0
    vcorrect = 0
    for batch_idx, (data, target) in enumerate(train_loader):
        if args.cuda:
            data, target = data.cuda(), target.cuda()
        data, target = Variable(data), Variable(target)

        optimizer.zero_grad()
        output = model(data, target)
        loss = F.nll_loss(output, target)
        loss.backward()
        optimizer.step()
        train_loss += F.nll_loss(output, target, size_average=False).item() # sum up batch loss
        pred = output.data.max(1, keepdim=True)[1] # get the index of the max log-probability
        correct += pred.eq(target.data.view_as(pred)).cpu().sum()		

        # validation would most likely go here...

        if batch_idx % args.log_interval == 0:
            print('Time', time.time()-start,'Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}'.format(
                epoch, batch_idx * len(data), len(train_loader.dataset),
                100. * batch_idx / len(train_loader), loss.data[0]))
#extra print for 
            print('Time', time.time()-start,'Valid Epoch: {} [{}/{} ({:.0f}%)]\tValid Loss: {:.6f}'.format(
                epoch, batch_idx * len(data), len(validate_loader.dataset),
                100. * batch_idx / len(validate_loader), loss.data[0]))

I want to add validation, i think it should look like this, eval every 10 steps
  if batch_idx % 10 == 0:
        	model.eval()
        	for data, target in validate_loader:
        		if args.cuda:
        			data, target = data.cuda(), target.cuda()
        		data, target = Variable(data), Variable(target)
        		voutput = model(data)
        		vloss += F.nll_loss(voutput, target, size_average=False).item()
        		vpred = voutput.data.max(1, keepdim=True)[1]
        		vcorrect += vpred.eq(target.data.view_as(vpred)).cpu().sum()

I have run into several problems
first is var issue: data,target are used for both train and validation however, pytorch errors out when i try and rename one of the data,train vars
Is this just implemented wrong in PyTorch ?