def forward(self, x, fileinfo): filenames = [nii_seq_tk.parse_filename(y) for y in fileinfo] datalength = [nii_seq_tk.parse_length(y) for y in fileinfo] if self.training: feature_vec = self._compute_embedding(x, datalength) scores = self._compute_score(feature_vec) # target target = self._get_target(filenames) target_vec = torch.tensor(target, device=x.device, dtype=torch.long) target_vec = target_vec.repeat(self.v_submodels) return [scores, target_vec] else: feature_vec = self._compute_embedding(x, datalength) scores = self._compute_score(feature_vec, True) target = self._get_target(filenames) print("Output, %s, %d, %f" % (filenames[0], target[0], scores.mean())) # don't write output score as a single file return None
def forward(self, x, fileinfo): #with torch.no_grad(): # vad_waveform = self.m_vad(x.squeeze(-1)) # vad_waveform = self.m_vad(torch.flip(vad_waveform, dims=[1])) # if vad_waveform.shape[-1] > 0: # x = torch.flip(vad_waveform, dims=[1]).unsqueeze(-1) # else: # pass filenames = [nii_seq_tk.parse_filename(y) for y in fileinfo] datalength = [nii_seq_tk.parse_length(y) for y in fileinfo] if self.training: feature_vec = self._compute_embedding(x, datalength) scores = self._compute_score(feature_vec) # target target = self._get_target(filenames) target_vec = torch.tensor(target, device=x.device).long() target_vec = target_vec.repeat(self.v_submodels) return [scores, target_vec, True] else: feature_vec = self._compute_embedding(x, datalength) score = self._compute_score(feature_vec, True) target = self._get_target(filenames) print("Output, %s, %d, %f" % (filenames[0], target[0], score.mean())) # don't write output score as a single file return None