(self, epoch, dataset, should_print=False, use_mask=True)
return acc
use_mask: mask the 0 label
use_mask: mask the 0 label
use_mask : mask the 0 label
def test_epoch(self, epoch, dataset, should_print=False, use_mask=True):
        """
        use_mask: mask the 0 label
        """
        self.model.eval()
        acc_list = []
        for index, data in tqdm(enumerate(dataset)):
            self._to_device(data)
            percent = index / len(dataset) * 100
            if should_print:
                print('[Epoch %d] Test | Data %d (%d%%): acc: | path: %s' % \
                (epoch, index, percent, data.path), ' ' * 30, end='\r')
            outputs = self.model(data.nodes, data.edges, data.adj, data.incidence)
            _lab_len = len(data.labels)
            if use_mask:
                for i in data.labels: 
                    if i == 0: _lab_len -= 1
                _labels = torch.LongTensor(
                    [(-1 if i == 0 else i) for i in data.labels]).to(self.device)
            else: _labels = data.labels
            acc = (outputs.max(dim=1)[1] == _labels).float().sum().item() / _lab_len
            acc_list.append(acc)
            # if index % 10 == 0:
            if should_print:
                print('[Epoch %d] Test | Data %d (%d%%): acc: %.3f | path: %s' % \
                (epoch, index, percent, acc, data.path), ' ' * 30, end='\n')
        acc = sum(acc_list) / len(acc_list)
        return acc
def test_epoch ( self , epoch , dataset , should_print = False , use_mask = True ) : self . model . eval ( ) acc_list = [ ] for index , data in tqdm ( enumerate ( dataset ) ) : self . _to_device ( data ) percent = index / len ( dataset ) * 100 if should_print : print ( '[Epoch %d] Test | Data %d (%d%%): acc: | path: %s' % ( epoch , index , percent , data . path ) , ' ' * 30 , end = '\r' ) outputs = self . model ( data . nodes , data . edges , data . adj , data . incidence ) _lab_len = len ( data . labels ) if use_mask : for i in data . labels : if i == 0 : _lab_len -= 1 _labels = torch . LongTensor ( [ ( - 1 if i == 0 else i ) for i in data . labels ] ) . to ( self . device ) else : _labels = data . labels acc = ( outputs . max ( dim = 1 ) [ 1 ] == _labels ) . float ( ) . sum ( ) . item ( ) / _lab_len acc_list . append ( acc ) # if index % 10 == 0: if should_print : print ( '[Epoch %d] Test | Data %d (%d%%): acc: %.3f | path: %s' % ( epoch , index , percent , acc , data . path ) , ' ' * 30 , end = '\n' ) acc = sum ( acc_list ) / len ( acc_list ) return acc