Hello again @ptrblck. I ask here because I don’t know if is a good idea create a new topic. If you think I should create a new topic, I will do it.
Reciently, I had studied my dataset, and I find I didn’t load correctly.
Now, I concatenate all examples correctly, and all is working almost correctly.
I have six dimensional matrixes, two for trains, two for test, and two for validation.
I deleted music_collate_fn because now I can use default function.
I make some changes in my code. Now, dataset class is much more easy:
class MusicDataSet(Dataset):
    def __init__(self, input_matrix, target_matrix, function=None):
        self.ms = input_matrix
        self.target = target_matrix

    def __len__(self):
        return len(self.ms)

    def __getitem__(self, idx):
        inp = torch.from_numpy(self.ms[idx].astype(np.float))
        target = torch.from_numpy(self.target[idx].astype(np.double))

        return inp, target

And the model is very simple:
class MLP(nn.Module):
    def __init__(self, input_dim, hidden_dim, output_dim):
        super(MLP, self).__init__()

        self.dense1 = nn.Linear(input_dim, hidden_dim[0]) 
        self.dense2 = nn.Linear(hidden_dim[0], hidden_dim[1])  
        self.dense3 = nn.Linear(hidden_dim[1], hidden_dim[2])      
        self.dense4 = nn.Linear(hidden_dim[2], output_dim)
        self.relu = nn.ReLU()
        self.sigm = nn.Sigmoid()
        self.dropout = nn.Dropout(0.05)
     
    def forward(self, x):
        x = self.dense1(x)
        x = self.relu(x)
        x = self.dense2(x)
        x = self.relu(self.dropout(x))
        x = self.dense3(x)
        x = self.relu(self.dropout(x))
        x = self.dense4(x)
        x = self.sigm(x)
        return x

Preprocess code:
X_train, Y_train, X_val, Y_val , X_test, Y_test = sd.loadDatasets()

trainSet = mds.MusicDataSet(X_train, Y_train)
valSet = mds.MusicDataSet(X_val, Y_val)
testSet = mds.MusicDataSet(X_test, Y_test)
train_loader = torch.utils.data.DataLoader(trainSet, batch_size=batch_size_train, shuffle=False)
test_loader = torch.utils.data.DataLoader(testSet, batch_size=batch_size_test, shuffle=False)
val_loader = torch.utils.data.DataLoader(valSet, batch_size=batch_size_val, shuffle=False)

input_dim = 252
hidden_dim = (500, 600, 100)
output_dim = 88
if CUDA:
   mlp = rn.MLP(input_dim, hidden_dim, output_dim).to('cuda') 
   mlp.double();

optimizer = torch.optim.SGD(mlp.parameters(), lr = learning_rate, momentum=momentum)
criterion = nn.BCELoss()

All matrixes are transposed when are loaded.
The input data shape has 252 elements in each row.
The target data shape has 88 elements in each row.
The num rows in trainSet is 656445 and less in the others Datasets.
I was checking the accuracy in test, but it is not enough, is very bad, less than 50%. I can’t understand why.
This is the code to train, eval and test the model:
def train(model, train_loader, optimizer, criterion):
    model.train()
    for idx_batch, (input,target) in enumerate(train_loader):
        optimizer.zero_grad()
        input = input.cuda()
        target = target.cuda()
        outputs = model(input) 
        loss = criterion(outputs, target)
        loss.backward()   
        optimizer.step()
        train_loss += loss.item()
    return train_loss

def val(model, val_loader, optimizer, criterion):
    model.eval()
    val_loss = 0
    with torch.no_grad():
        for idx_batch, (input, target) in enumerate(val_loader):
             input = input.cuda()
             target = target.cuda()
            outputs = model(input)
            loss = criterion(outputs, target)
            val_loss += loss.item()
    return val_loss

for epoch in range(1, N_EPOCHS+1):
    print("------------EPOCHS ",epoch,"------------")
    train_loss = 0
    val_loss = 0
    train_loss = train(mlp, train_loader, optimizer, criterion)
    val_loss = val(mlp, val_loader, optimizer, criterion)
    
    #Mean of losses
    train_loss = train_loss/len(train_loader.dataset)
    val_loss = val_loss/len(val_loader.dataset)
    
    #Stats training and validation.
    print('Epoch: {} \tTraining loss: {:.6f} \tValidation loss:{:.6f}'.format(epoch, train_loss, val_loss))
    
#Training
mlp.eval()
for data, target in test_loader:

    data = data.to('cuda')
    target = target.to('cuda')
    outputs = mlp(data)
    loss = criterion(outputs, target)
    test_loss += loss.item() #*data.size(0)????
    pred = torch.max(outputs, 1)[1]
    t = torch.max(target, 1)[1]
    correct += pred.eq(t).sum()


Thanks so much.