# cost = w * cost_material_a + (1-w) * cost_material_b
# then you can scale w in a way that makes it more 'strict', so e.g. with a sigmoid(10*(w-0.5)) (please plot that and check if that makes sense before using it)
defsigmoid(number):
return1/(1+torch.exp(-number))
...
...
@@ -168,7 +166,7 @@ class Optimizer(object):
reco_surrogate_loss=0
constraint_loss=0
forepochinrange(n_epochs):
batch_mean_loss=0
batch_mean_loss=0# To use last epochs only
batch_reco_surrogate_loss=0
batch_constraint_loss=0
stop_epoch=False
...
...
@@ -226,21 +224,22 @@ class Optimizer(object):
batch_mean_loss/=(batch_idx+1)
batch_reco_surrogate_loss/=(batch_idx+1)
batch_constraint_loss/=(batch_idx+1)
ifepoch==(n_epochs-1):
ifepoch==(n_epochs-1):# Only using Last Epochs(Remove this conditional to use more)