model.py
def forward(self, x, dropout=False):
        """
        Performs forward propagation with SelectiveNet.
        :param x: The input image batch.
        :param dropout: Boolean if dropout should be applied.
        :return: Predictions, Selective score and auxiliary output.
        """

        # Performs forward propagation with the EfficientNet encoder.
        x = self.encoder.extract_features(x)
        x = self.encoder_pool(x)
        x = x.view(x.shape[0], -1)

        # Applies dropout if selected.
        if dropout:
            x = F.dropout(x, self.drop_rate)

        # Uses the hidden layer.
        x = self.hidden(x)

        # Applies dropout if selected.
        if dropout:
            x = F.dropout(x, self.drop_rate)

        # Gets the predictive output of the model.
        x1 = self.classifier(x)

        # Gets the selective output of the model.
        x2 = F.relu(self.selective_hidden(x))
        x2 = self.selective_batch_norm(x2)
        x2 = torch.sigmoid(self.selective_regression(x2))

        # Gets the auxiliary output of the model.
        x3 = self.auxiliary_output(x)

        # Returns the outputs of the model.
        return x1, x2, x3

        Performs forward propagation with SelectiveNet.
        :param x: The input image batch.
        :param dropout: Boolean if dropout should be applied.
        :return: Predictions, Selective score and auxiliary output.
        
Performs forward propagation with SelectiveNet.
Performs forward propagation with SelectiveNet .
def forward(self, x, dropout=False):
        x = self.encoder.extract_features(x)
        x = self.encoder_pool(x)
        x = x.view(x.shape[0], -1)
        if dropout:
            x = F.dropout(x, self.drop_rate)
        x = self.hidden(x)
        if dropout:
            x = F.dropout(x, self.drop_rate)
        x1 = self.classifier(x)
        x2 = F.relu(self.selective_hidden(x))
        x2 = self.selective_batch_norm(x2)
        x2 = torch.sigmoid(self.selective_regression(x2))
        x3 = self.auxiliary_output(x)
        return x1, x2, x3
def forward ( self , x , dropout = False ) : x = self . encoder . extract_features ( x ) x = self . encoder_pool ( x ) x = x . view ( x . shape [ 0 ] , - 1 ) if dropout : x = F . dropout ( x , self . drop_rate ) x = self . hidden ( x ) if dropout : x = F . dropout ( x , self . drop_rate ) x1 = self . classifier ( x ) x2 = F . relu ( self . selective_hidden ( x ) ) x2 = self . selective_batch_norm ( x2 ) x2 = torch . sigmoid ( self . selective_regression ( x2 ) ) x3 = self . auxiliary_output ( x ) return x1 , x2 , x3
Performs forward propagation with SelectiveNet.
Performs forward propagation with SelectiveNet .
"""
        Performs forward propagation with SelectiveNet.
        :param x: The input image batch.
        :param dropout: Boolean if dropout should be applied.
        :return: Predictions, Selective score and auxiliary output.
        """ # Performs forward propagation with the EfficientNet encoder. # Applies dropout if selected. # Uses the hidden layer. # Applies dropout if selected. # Gets the predictive output of the model. # Gets the selective output of the model. # Gets the auxiliary output of the model. # Returns the outputs of the model.
Predictions, Selective score and auxiliary output.
Predictions Selective score and auxiliary output .
self
x
The input image batch.
The input image batch .
dropout
Boolean if dropout should be applied.
Boolean if dropout should be applied .