ptrblck:

Is it a typo


Yeah it’s a typo in the example code posted. In my actual code I have a python One-Liner:
anchor, positive, negative = [model(torch.tensor([[x]]).float()) for x in triplet]

The above example corrected would be:
for index, triplet in enumerate(data):
    optimizer.zero_grad()

    anchor = model(torch.tensor([[triplet[0]]]).float()
    positive = model(torch.tensor([[triplet[1]]]).float()
    negative = model(torch.tensor([[triplet[2]]]).float()

    loss = criterion(anchor, positive, negative)
    loss.backward()
    optimizer.step()

    # print error and others every 100 iters.

My intend was to post clearer(easier  to read) code, I’ve clearly failed miserably since it caused more confusion.