Skip to main content
. 2024 Mar 4;14(5):543. doi: 10.3390/diagnostics14050543
Algorithm 1: Algorithm for Segmentation using UNet and Transformers
Input: X as the input image, ci as the output of the ith convolutional layer in the UNet model, fi as the ith feature map, pi as the ith pooling layer, ui as the ith up-convolutional (transposed convolutional) layer in the U-Net model, ti as the output of the transformer model, mi as the multi-head attention mechanism in the transformer model, di as the ith dense layer in the transformer model.
Output: Segmented Lesion
1. for i in range(N) do:
           E = sigma(Conv(E-1))
           D = sigma(Conv(D-1)
           S = E + D
           L_bce = sum(y_i × log(O_i) + (1 − y_i) × log(1 − O_i) for i in range(N))
           L_dice = (2 × TP)/((TP + FP) + (TP + FN))
           L_jaccard = TP/(TP + FP + FN)
end for
# Transformer-style segmentation with MultiHeadAttention, Position-wise Feed-forward Network, and Normalization
2. for i in range(N) do:
                     E = MultiHeadAttention_Layer(x) + x
                     D = MultiHeadAttention(Y) + Y + MultiHeadAttention(Encoder_Output)
           FFN = ReLU(Conv1D(Z, W_1 + b_1)) @ W_2 + b_2
end for