tools/utilities/pythonlibs/audio/training/train_classifier.py
def evaluate(self, test_data, batch_size, device=None):
        """
        Evaluate the given test data and print the pass rate
        """
        self.eval()
        passed = 0
        total = 0
        self.zero_grad()
        with torch.no_grad():        
            for i_batch, (audio, labels) in enumerate(test_data.get_data_loader(batch_size)):
                batch_size = audio.shape[0]
                audio = audio.transpose(1,0) # GRU wants seq,batch,feature
                if device:
                    audio = audio.to(device)
                    labels = labels.to(device)
                total += batch_size
                self.init_hidden()
                keyword_scores = self(audio)     
                last_accuracy, ok = self.batch_accuracy(keyword_scores, labels)
                passed += ok
        
        return (passed, total, passed / total)

        Evaluate the given test data and print the pass rate
        
Evaluate the given test data and print the pass rate
Evaluate the given test data and print the pass rate
def evaluate(self, test_data, batch_size, device=None):
        self.eval()
        passed = 0
        total = 0
        self.zero_grad()
        with torch.no_grad():        
            for i_batch, (audio, labels) in enumerate(test_data.get_data_loader(batch_size)):
                batch_size = audio.shape[0]
                audio = audio.transpose(1,0) 
                if device:
                    audio = audio.to(device)
                    labels = labels.to(device)
                total += batch_size
                self.init_hidden()
                keyword_scores = self(audio)     
                last_accuracy, ok = self.batch_accuracy(keyword_scores, labels)
                passed += ok
        return (passed, total, passed / total)
def evaluate ( self , test_data , batch_size , device = None ) : self . eval ( ) passed = 0 total = 0 self . zero_grad ( ) with torch . no_grad ( ) : for i_batch , ( audio , labels ) in enumerate ( test_data . get_data_loader ( batch_size ) ) : batch_size = audio . shape [ 0 ] audio = audio . transpose ( 1 , 0 ) if device : audio = audio . to ( device ) labels = labels . to ( device ) total += batch_size self . init_hidden ( ) keyword_scores = self ( audio ) last_accuracy , ok = self . batch_accuracy ( keyword_scores , labels ) passed += ok return ( passed , total , passed / total )
Evaluate the given test data and print the pass rate
Evaluate the given test data and print the pass rate
"""
        Evaluate the given test data and print the pass rate
        """ # GRU wants seq,batch,feature
self
test_data
batch_size
device