Absolutely. I did take your suggestion and try torch.tanh instead of torch.max and got an error  “The size of tensor a (2) must match the size of tensor b (64) at non-singleton dimension 0” when i used mult = outputs * labels in the loss function.
Use case -
a) I am using MNIST dataset and implementing a image classification to classify handwritten digit 0 and 1 only using the below code.
b) Then using Logistic regression model :
model = nn.Linear(input_size,num_classes)
c) Created the custom loss function that is above : Regress_Loss
d) Training the model where in  I converted the labels from 0,1 to -1,1:
#Convert labels from 0,1 to -1,1
labels = Variable(2*(labels.float()-0.5))
e) Determining Loss with the below statements:
Forward pass
    outputs = model(images)
    # maximum value of two class prediction 
    oneout = torch.max(outputs.data, 1)[0]**
    ## exploring if converting the outputs to be same as labels (1,-1) will help
    oneout[oneout < 0] = -1
    oneout[oneout > 0] = 1
    loss = loss_criteria(oneout, labels)        
    # Backward and optimize
    optimizer.zero_grad()
    loss.backward()
    optimizer.step()   

   Then I am printing loss.

-----code for bullet (a)------------
subset_indices = ((train_data.train_labels == 0) + (train_data.train_labels == 1)).nonzero().view(-1)
train_loader = torch.utils.data.DataLoader(dataset=train_data,
batch_size=batch_size,
shuffle=False,
sampler=SubsetRandomSampler(subset_indices))