Define the total loss, which is the weighted sum of the margin loss and the reconstructed loss:
alpha = 0.0005
total_loss = margin_loss + alpha * reconstruction_loss
Optimize the loss using the Adam optimizer:
optimizer = tf.train.AdamOptimizer(0.0001)
train_op = optimizer.minimize(total_loss)