I tried that, but it returns me an error.
criterion = nn.CrossEntropyLoss
#criterion = F.binary_cross_entropy
def train( model, train_loader, optimizer, criterion):
    model.train()
for batch_idx, (input,target) in enumerate(train_loader):
        optimizer.zero_grad()           #Gradientes a cero  
        outputs = model(input) 
        target = torch.argmax(target, 1)
        loss = criterion(outputs, target)
        temp_loss.append(loss.item())
 
        loss.backward()                 #Back propagation
        optimizer.step()                #Actualizar parámetros.


I obtain the next error:

  File "<ipython-input-17-1aec7df1fd6b>", line 69, in <module>
    train_losses += train(epoch, mlp, train_loader, optimizer, criterion)

  File "<ipython-input-17-1aec7df1fd6b>", line 15, in train
    loss = criterion(outputs, target)

  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\loss.py", line 898, in __init__
    super(CrossEntropyLoss, self).__init__(weight, size_average, reduce, reduction)

  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\loss.py", line 23, in __init__
    super(_WeightedLoss, self).__init__(size_average, reduce, reduction)

  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\loss.py", line 16, in __init__
    self.reduction = _Reduction.legacy_get_string(size_average, reduce)

  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\_reduction.py", line 42, in legacy_get_string
    if size_average and reduce:

RuntimeError: bool value of Tensor with more than one value is ambiguous