(self, data_loader: FTLDataLoader)
return phi, overlap_ua
compute Φ and ua of overlap samples
compute Φ and ua of overlap samples
compute Φ and ua of overlap samples
def compute_phi_and_overlap_ua(self, data_loader: FTLDataLoader):

        """
        compute Φ and ua of overlap samples
        """

        phi = None  # [1, feature_dim]  Φ_A
        overlap_ua = []
        for i in range(len(data_loader)):
            batch_x, batch_y = data_loader[i]
            ua_batch = self.nn.predict(batch_x)  # [batch_size, feature_dim]

            relative_overlap_index = data_loader.get_relative_overlap_index(i)
            if len(relative_overlap_index) != 0:
                if self.verbose:
                    LOGGER.debug('batch {}/{} overlap index is {}'.format(i, len(data_loader), relative_overlap_index))
                overlap_ua.append(ua_batch[relative_overlap_index])

            phi_tmp = np.expand_dims(np.sum(batch_y * ua_batch, axis=0), axis=0)
            if phi is None:
                phi = phi_tmp
            else:
                phi += phi_tmp

        phi = phi / self.data_num

        return phi, overlap_ua
def compute_phi_and_overlap_ua ( self , data_loader : FTLDataLoader ) : phi = None # [1, feature_dim]  Φ_A overlap_ua = [ ] for i in range ( len ( data_loader ) ) : batch_x , batch_y = data_loader [ i ] ua_batch = self . nn . predict ( batch_x ) # [batch_size, feature_dim] relative_overlap_index = data_loader . get_relative_overlap_index ( i ) if len ( relative_overlap_index ) != 0 : if self . verbose : LOGGER . debug ( 'batch {}/{} overlap index is {}' . format ( i , len ( data_loader ) , relative_overlap_index ) ) overlap_ua . append ( ua_batch [ relative_overlap_index ] ) phi_tmp = np . expand_dims ( np . sum ( batch_y * ua_batch , axis = 0 ) , axis = 0 ) if phi is None : phi = phi_tmp else : phi += phi_tmp phi = phi / self . data_num return phi , overlap_ua