-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added the transformation for maco #60
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #60 +/- ##
==========================================
+ Coverage 83.03% 91.70% +8.66%
==========================================
Files 22 19 -3
Lines 825 747 -78
==========================================
Hits 685 685
+ Misses 140 62 -78 ☔ View full report in Codecov by Sentry. |
Subject: Request for Assistance with PyTorch Function Implementation Hey @Mayukhdeb, Here's a summary of what the function does:
Would you mind taking a look at the draft TensorFlow function and helping me adapt it to PyTorch? I've attached the code snippet below for reference: def compile_objectives(self) -> Tuple[tf.keras.Model, Callable, List[str], Tuple]:
"""
Compile all the sub-objectives into one and return the objects
for the optimization process.
Returns
-------
modified_model
Model with the outputs needed for the optimization.
loss_calculator
Function to compute the loss for the objectives.
objective_names
Names of each objective.
input_shape
Shape of the input, one sample for each optimization.
"""
num_objectives = len(self.multipliers)
# Rearrange masks to match different objectives with model outputs
mask_combinations = np.array([np.array(m, dtype=object) for m in itertools.product(*self.masks)])
mask_tensors = [tf.cast(tf.stack(list(mask_combinations[:, i])), tf.float32) for i in range(num_objectives)]
# Concatenate names for each combination of objectives
objective_names = np.array([' & '.join(names) for names in itertools.product(*self.names)])
# Define multipliers for each sub-objective
objective_multipliers = tf.constant(self.multipliers)
def compute_loss(model_outputs):
total_loss = 0.0
for index in range(num_objectives):
outputs = model_outputs[index]
total_loss += self.funcs[index](
outputs, tf.cast(mask_tensors[index], outputs.dtype))
total_loss *= objective_multipliers[index]
return total_loss
# Create the modified model with necessary layers
modified_model = tf.keras.Model(self.model.input, [*self.layers])
num_combinations = mask_tensors[0].shape[0]
input_shape = (num_combinations, *modified_model.input.shape[1:])
return modified_model, compute_loss, objective_names, input_shape Any insights, suggestions, or code snippets you could provide would be greatly appreciated! Let me know if you have any questions or need further clarification on anything. Looking forward to your guidance! |
the main problem is coming near the modified model part.. |
issue #57