<jupyter_start><jupyter_text>The audio files are inside a subfolder `audio/`<jupyter_code>(path/"audio").ls()<jupyter_output><empty_output><jupyter_text>And there's another folder `meta/` with some metadata about all the files and the labels<jupyter_code>(path/"meta").ls()<jupyter_output><empty_output><jupyter_text>Opening the metadata file<jupyter_code>df = pd.read_csv(path/"meta"/"esc50.csv")
df.head()<jupyter_output><empty_output><jupyter_text>Looking at the fold attribute, this dataset has a 5 fold cross validation setup<jupyter_code>df["fold"].value_counts()<jupyter_output><empty_output><jupyter_text>Datablock and Basic End to End Training on 10 Speakers<jupyter_code>def CrossValidationSplitter(col='fold', fold=1):
    "Split `items` (supposed to be a dataframe) by fold in `col`"
    def _inner(o):
        assert isinstance(o, pd.DataFrame), "ColSplitter only works when your items are a pandas DataFrame"
        col_values = o.iloc[:,col] if isinstance(col, int) else o[col]
        valid_idx = (col_values == fold).values.astype('bool')
        return IndexSplitter(mask2idxs(valid_idx))(o)
    return _inner
cfg = AudioConfig.BasicMelSpectrogram()
a2s = AudioToSpec.from_cfg(cfg)
auds = DataBlock(blocks=(AudioBlock, CategoryBlock),  
                 get_x=ColReader("filename", pref=path/"audio"), 
                 splitter=CrossValidationSplitter(fold=1),
                 batch_tfms = [a2s],
                 get_y=ColReader("category"))
dbunch = auds.dataloaders(df, bs=64)
dbunch.show_batch(figsize=(10, 5))<jupyter_output><empty_output><jupyter_text>10 epochs<jupyter_code>accuracies = []

for i in range(5):
    learn = cnn_learner(dbunch, 
                    resnet18, 
                    config=cnn_config(n_in=1),
                    loss_fn=CrossEntropyLossFlat,
                    metrics=[accuracy]                 
                    )
    
    learn.fit_one_cycle(10)
    accuracies.append(learn.recorder.values[-1][-1])

print(sum(accuracies) / 5)<jupyter_output><empty_output><jupyter_text>20 epochs<jupyter_code>accuracies = []

for i in range(5):
    learn = cnn_learner(dbunch, 
                    resnet18, 
                    config=cnn_config(n_in=1),
                    loss_fn=CrossEntropyLossFlat,
                    metrics=[accuracy]                 
                    )
    
    learn.fit_one_cycle(20)
    accuracies.append(learn.recorder.values[-1][-1])

print(sum(accuracies) / 5)<jupyter_output><empty_output><jupyter_text>80 epochs<jupyter_code>accuracies = []


learn = cnn_learner(dbunch, 
                resnet18, 
                config=cnn_config(n_in=1),
                loss_fn=CrossEntropyLossFlat,
                metrics=[accuracy],
                cbs=[MixUp()] #<- Mixup
                )


learn.fit_one_cycle(80)

print(learn.recorder.values[-1][-1])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11844863731656184, 'fraction_numerical': 0.01607267645003494, 'mean_word_length': 3.0380818053596617, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '242085', 'license': 'MIT', 'n_tokens_mistral': 1001, 'n_tokens_neox': 943, 'n_words': 150, 'path': 'ESC-50-baseline-1Fold.ipynb', 'repo_name': 'fastaudio/Audio-Competition', 'size': '2862'}