Skip to content

Commit

Permalink
feat(Classifier): Removed two_dim parameter from Classifier
Browse files Browse the repository at this point in the history
  • Loading branch information
muellerdo committed May 28, 2022
1 parent 1f38ce5 commit 09d4b13
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions aucmedi/neural_network/architectures/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(self, n_labels, activation_output="softmax",
#---------------------------------------------#
# Create Model #
#---------------------------------------------#
def build(self, model_input, model_output, two_dim=True):
def build(self, model_input, model_output):
""" Internal function which appends the classification head.
This function will be called inside of an [Architecture][aucmedi.neural_network.architectures] `create_model()` function
Expand All @@ -141,16 +141,17 @@ def build(self, model_input, model_output, two_dim=True):
Args:
model_input (tf.keras layer): Input layer of the model.
model_output (tf.keras layer): Output layer of the model.
two_dim (bool): Boolean, whether architecture is 2D or 3D.
Returns:
model (tf.keras model): A functional Keras model.
"""
# Apply GlobalAveragePooling to obtain a single spatial dimensions
if two_dim:
if len(model_output.shape) == 4: # for 2D architectures
model_head = layers.GlobalAveragePooling2D(name="avg_pool")(model_output)
else:
elif len(model_output.shape) == 5: # for 3D architectures
model_head = layers.GlobalAveragePooling3D(name="avg_pool")(model_output)
# if not model output shape 4 or 5 -> it is already GlobalAveragePooled to 2 dim
else : model_head = model_output

# Apply optional dense & dropout layer
if self.fcl_dropout:
Expand Down

0 comments on commit 09d4b13

Please sign in to comment.