Skip to content

Commit

Permalink
Add option to change output activation in transferlearn
Browse files Browse the repository at this point in the history
  • Loading branch information
erceksi committed Sep 23, 2024
1 parent b0ed978 commit ac84f35
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/crested/tl/_crested.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ def transferlearn(
learning_rate_first_phase: float = 1e-4,
learning_rate_second_phase: float = 1e-6,
dense_block_name: str = "denseblock",
set_output_activation: str | None = None,
**kwargs,
):
"""
Expand All @@ -404,6 +405,8 @@ def transferlearn(
Learning rate for the second phase.
mixed_precision
Enable mixed precision training.
set_output_activation
Set outpu activation if different from the previous model.
kwargs
Additional keyword arguments to pass to the fit method.
Expand Down Expand Up @@ -442,7 +445,10 @@ def transferlearn(

# Change the number of output units to match the new task
old_activation_layer = base_model.layers[-1]
old_activation = old_activation_layer.activation
if set_output_activation is None:
old_activation = old_activation_layer.activation
else set_output_activation:
old_activation = keras.activations.get(set_output_activation)

x = base_model.layers[-3].output
new_output_units = self.anndatamodule.adata.X.shape[0]
Expand Down

0 comments on commit ac84f35

Please sign in to comment.