autoth/core.py
def calculate_gradients(self, params):
        """Calculate gradient of thresholds numerically.
        Args:
          y_true: (N, (optional)frames_num], classes_num)
          output: (N, (optional)[frames_num], classes_num)
          thresholds: (classes_num,), initial thresholds
          average: 'micro' | 'macro'
        Returns:
          grads: vector
        """
        score = self.score_calculator(params)
        step = self.step
        grads = []

        for k, param in enumerate(params):
            new_params = params.copy()
            cnt = 0
            while cnt < self.max_search:
                cnt += 1
                new_params[k] += self.step
                new_score = self.score_calculator(new_params)

                if new_score != score:
                    break

            grad = (new_score - score) / (step * cnt)
            grads.append(grad)

        return score, grads
Calculate gradient of thresholds numerically.
        Args:
          y_true: (N, (optional)frames_num], classes_num)
          output: (N, (optional)[frames_num], classes_num)
          thresholds: (classes_num,), initial thresholds
          average: 'micro' | 'macro'
        Returns:
          grads: vector
        
Calculate gradient of thresholds numerically.
Calculate gradient of thresholds numerically .
def calculate_gradients(self, params):
        score = self.score_calculator(params)
        step = self.step
        grads = []
        for k, param in enumerate(params):
            new_params = params.copy()
            cnt = 0
            while cnt < self.max_search:
                cnt += 1
                new_params[k] += self.step
                new_score = self.score_calculator(new_params)
                if new_score != score:
                    break
            grad = (new_score - score) / (step * cnt)
            grads.append(grad)
        return score, grads
def calculate_gradients ( self , params ) : score = self . score_calculator ( params ) step = self . step grads = [ ] for k , param in enumerate ( params ) : new_params = params . copy ( ) cnt = 0 while cnt < self . max_search : cnt += 1 new_params [ k ] += self . step new_score = self . score_calculator ( new_params ) if new_score != score : break grad = ( new_score - score ) / ( step * cnt ) grads . append ( grad ) return score , grads
Calculate gradient of thresholds numerically.
Calculate gradient of thresholds numerically .
"""Calculate gradient of thresholds numerically.
        Args:
          y_true: (N, (optional)frames_num], classes_num)
          output: (N, (optional)[frames_num], classes_num)
          thresholds: (classes_num,), initial thresholds
          average: 'micro' | 'macro'
        Returns:
          grads: vector
        """
None
grads
self
params
y_true
(N, (optional)frames_num], classes_num)
( N ( optional ) frames_num ] classes_num )
output
(N, (optional)[frames_num], classes_num)
( N ( optional ) [ frames_num ] classes_num )
thresholds
(classes_num,), initial thresholds
( classes_num ) initial thresholds
average
'micro' | 'macro'
' micro ' | ' macro '