I have an output vector with logits, like [ 0.123, 2.111, 3.222, -0.234, 0.234 ] and I want to push the 3.222 value down to 2.222, for the same input (so, the next output vector could look like [ 0.023, 1.345, 2.222, -0.234, -0.123 ]; other values can be any, but 2.222 must be there, ok, maybe with some slight error, like 2.224). What method can I use?
Like this?
model_ouputs=model(data_batch)
targets=model_outputs.detach()
targets[:,2:3]=targets[:,2:3]-1
loss=optimizer(model_outputs, targets)
(Assumes dim=0 is batch dimension.)
Is this what you mean?
loss = MSELoss()
for input in dataloader:
optimizer.zero_grad()
your_logits_vector = model(input)
l = loss(your_logits_vector, [0, 0, 2.222, 0, 0])
l.backward()
optimizer.step()