Giter Site home page Giter Site logo

dnn-mgr's Introduction

##About This repository contains research code for experimenting with deep neural networks (DNNs) for music genre recognition (MGR). For the moment the repository contains many test scripts and should be considered unstable (i.e., the code is subject to change given our experimental needs). Nonetheless, the instructions below should help you reproduce our experiments and identify which files are most important for the basic functionality.

##Requirements

  • Python (Tested with version 2.7. Note Python 3 contains many changes that might introduce bugs in this code)
  • NumPy
  • SciPy
  • PyTables (requires numexpr and libhdf5)
  • Theano
  • Pylearn2
  • scikits.audiolab (and libsndfile)
  • scikits-learn

You can find some setup tips in the hpc_scripts folder of this repository

##V2.0 Instructions This version is more flexible than the previous version and has been designed to work with generic datasets (not only the Tzanetakis dataset), with arbitrary categorical labels, and excerpt lengths.

###Dataset organization: Audio files must be uncompressed in either WAV or AU format and many different types of directory structures are permissible. However, there must be a way of specifying the categorical label for each file in the dataset. This can be done either by embedding the label in the filename, or the name of the parent folder (the folder name will always take precedence in the case of a conflict).

In order to handle large datasets that may not fit into RAM this code requires that the dataset first be saved as a hdf5 file, which can be partially loaded into RAM on demand during training and testing. The script prepare_dataset.py will search for the dataset files, and prepare the hdf5 file. Furthermore, the prepare_dataset.py script can generate train/validation/test configuration files that specify a partition to be used in an experiment (e.g., 10-fold cross-validation). The partition configuration contains important meta-data, such as the train/valid/test files (and their index in the hdf5 file), as well as the mean and standard deviation of the training set (which can be used to standardize the data for training, validation, and testing).

The following instructions demonstrate an example of how to use the code: ####1. Prepare the dataset and partition configuration file(s):

python prepare_dataset.py \
	/path/to/dataset \
	/path/to/label_list.txt \
	--hdf5 /path/to/save/dataset.hdf5 \
	--train_prop 0.5 \
	--valid_prop 0.25 \
	--test_prop 0.25 \
	--partition_name /path/to/save/partition_configuration.pkl \
	--compute_std
	--tframes 100

This will create the hdf5 dataset file and generate (1/test_prop) stratified partitions. The label_list.txt is a comma or newline separated list of the categorical labels in the dataset (which are matched against file and/or folder names)

Alternatively the user can use a list of files when creating the partition:

python prepare_dataset.py \
	/path/to/dataset \
	/path/to/label_list.txt \
	--hdf5 /path/to/save/dataset.hdf5 \
	--train /path/to/train_list.txt \
	--valid /path/to/valid_list.txt \
	--test /path/to/test_list.txt \
	--partition_name /path/to/save/partition_configuration.pkl \
	--compute_std
	--tframes 100

The lists should be newline separated, and contain the relative path to each file (from the root folder of the dataset). For example if the directory structure is as follows:

/root/blues/file.wav
/root/jazz/file.wav

.
.
.

then the training list text file should look like this:

blues/file.wav
jazz/file.wav

run: python prepare_dataset.py --help to see a full list of options

####2. Train a DNN:

python train_mlp_script.py \
	/path/to/partition_configuration.pkl \
	/path/to/yaml_config_file.yaml \
	--nunits 50
	--output /path/to/save/model_file.pkl

Some yaml configuration files are provided in the folder yaml_scripts (but you can write your own for different experiments).

####3. Test a previously trained and saved DNN:

python test_mlp_script.py \
	/path/to/saved/model_file.pkl \
	--majority_vote

The model knows which dataset it was trained on, and will use the associated test set. An alternative testset can also be specified:

python test_mlp_script.py \
	/path/to/saved/model_file.pkl \
	--testset /path/to/alternate/partition_configuration.pkl
	--save_file /path/to/savefile.txt

--save_file lets the user save the test results to a file

##V1.0 Instructions This version has now been removed, but can be checked out as a branch using the v1.0 tag.

dnn-mgr's People

Contributors

coreyker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dnn-mgr's Issues

A question on "audio_dataset2d"

I read your paper "Deep learning and music adversaries" and I am doing some experiments with your source code.
I tried to train my dataset with "mlp_rlu_conv2.yaml" after preparation by using "prepare_dataset.py", but it returns an error message "The value of a Conv2DSpace batch must be 4D".

I also looked for the file "audio_dataset2d", but there was no "audio_dataset2d.py".

What do I have to do before training with the convolutional neural network?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.