This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def squeeze_collate(batch): | |
batch_x, batch_y = list(zip(*batch)) | |
batch_y = np.array(batch_y, dtype=np.float32) | |
batch_y = torch.from_numpy(batch_y) | |
batch_x = torch.cat(batch_x, dim=0) | |
return batch_x, batch_y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NoiseDataSet(Dataset): | |
def __init__(self, X, y): | |
super().__init__() | |
assert(len(X) == len(y)) | |
self.X = X | |
self.y = y | |
def __len__(self): | |
return len(self.X) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from pathlib import Path | |
def get_ytid(x): | |
name = Path(x).name | |
ytid = name[: name.rfind('_')] | |
return ytid | |
maybe_noise = pd.read_csv('Engine+noises_2020-08-24T19_34_31.csv') | |
maybe_healthy = pd.read_csv('Engine+healthy_2_2020-08-24T22_17_40.csv') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NoiseClassifier(nn.Module): | |
def __init__(self): | |
super().__init__() | |
self.vgg = vggish(preprocess=False, postprocess=False) | |
self.vgg.embeddings = nn.Sequential( | |
nn.Linear(512 * 4 * 6 * WINDOW_MULTIPLIER, 256), | |
nn.ReLU(True), | |
nn.Linear(256, 256), | |
nn.ReLU(True), | |
nn.Linear(256, 256), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import imap, ifilter | |
class map: | |
def __init__(self, callable): | |
self.callable = callable | |
def __ror__(self, *iterable): | |
return imap(self.callable, *iterable) | |
class filter: |
OlderNewer