matlab分时代码-learning-music-features:DartmouthCS74(机器学习)最终项目:由Olsh

  • e4_564700
    了解作者
  • 34.4MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-06 01:33
    上传日期
matlab分时代码 自述文件:基本音乐功能的无监督学习 理查德·兰格(Richard Lange) 迭代稀疏编码 我实现的算法称为迭代稀疏编码(ISC),并在中引入。 我对应的代码是par_iterative_sparse_coding.m 。 (它以前是iterative_sparse_coding.m但是后来我添加了并行化,并停止使用其他更改来更新旧版本)。 这是该算法工作原理的概述: 给定一组训练图像I ,学习一组基本函数(特征),它们可以最好地通过线性组合稀疏地重建原始图像。 这里,“稀疏”是指重建权重的大小。 要学习的功能数量是由用户预先设置的。 图像j重建定义如下: ![](images / I hat.png) 使用给定的,为每个图像学习一个向量。 的密度(负稀疏性)定义为 其中S(x)是在x=0处最小的函数。 是一个超参数。 作者提出了三个选择(第三个是最直观的,前两个在数学上更好地工作): 该算法非常简单:将误差E最小化,误差E定义为重建误差和密度的加权和。 图像j重建错误很简单 ![](图像/重建错误j.png) 则误差函数为 是控制R和D相对权重的超参数。 我在
learning-music-features-master.zip
  • learning-music-features-master
  • midi_lib
  • private
  • stuffit.gif
    240B
  • distance.m
    1.6KB
  • xcorr.m
    10.1KB
  • onsetmodmeter.m
    781B
  • matlab.gif
    534B
  • pdf.gif
    866B
  • nmat.mid
    239B
  • ofacorr.m
    357B
  • zip.gif
    1.1KB
  • logo.gif
    2.8KB
  • dursec.m
    498B
  • onsetsec.m
    506B
  • onsetfunc.m
    1KB
  • exptimewindow.m
    1.5KB
  • style.css
    2.6KB
  • mf2tsrc
  • example4.txt
    11.5KB
  • t2mf.o
    10.8KB
  • makefile.st
    1.1KB
  • mf2t.exe
    27.8KB
  • example3.mid
    117B
  • example2.mid
    118B
  • example3.txt
    428B
  • new.mid
    83B
  • tmwtypes.h
    6KB
  • Error.h
    1.4KB
  • mf2t.c_orig
    8.5KB
  • n.txt
    317B
  • t2mflex.c
    37.9KB
  • mf2tmex.c
    7.9KB
  • crack.o
    998B
  • text2midi.exe
    39.4KB
  • t2.dll
    27.5KB
  • makefile.unx
    951B
  • xy.dll
    4.5KB
  • example4.mid
    1.8KB
  • text2midi.dll
    27.5KB
  • yyread.c
    685B
  • crack.c
    4.2KB
  • example5.txt
    5.5KB
  • t2mf_.c
    11.9KB
  • README.TXT
    8.7KB
  • midif.dll
    15.5KB
  • mf2t.c
    8KB
  • xtimesy.c
    529B
  • makefile.msc
    1.1KB
  • midi.c
    1.5KB
  • yprime.dll
    5KB
  • strerror.c
    21.6KB
  • mat.h
    7.4KB
  • makefil2.~ms
    1.2KB
  • mf2t.prj
    896B
  • example5.mid
    1016B
  • example2.txt
    376B
  • t2mflex.o
    13.6KB
  • mex.h
    10KB
  • matrix.h
    23.9KB
  • makefil2.msc
    1.2KB
  • MF2T.OUT
    12KB
  • testmex.mid
    2.1KB
  • example1.mid
    81B
  • midifile.o
    9.1KB
  • makefile.bcc
    1.1KB
  • t2mf.h
    1.1KB
  • mf2tgate.c
    1.1KB
  • midifile.c
    21.9KB
  • midi.prj
    985B
  • mf2t.dll
    15.5KB
  • midifile.h
    3.4KB
  • example1.txt
    317B
  • mf2tgate.zip
    617B
  • strerror.o
    4.4KB
  • midifile.c_orig
    22.1KB
  • e.txt
    449B
  • narmour.m
    5.7KB
  • midi2hz.m
    526B
  • t2mfmac.app
    47.5KB
  • meteraccent.m
    1.1KB
  • channel.m
    409B
  • notename.m
    765B
  • compltrans.m
    1.6KB
  • trim.m
    582B
  • complebm.m
    3.4KB
  • maxkkcc.m
    776B
  • .DS_Store
    12KB
  • playmidi.m
    2.3KB
  • mdemo8.m
    5.5KB
  • filtercoll.m
    1.3KB
  • contents.m
    5.5KB
  • mftxt2nmat.m
    4.3KB
  • analyzecoll.m
    1.7KB
  • mdemo6.m
    2.6KB
  • t2mf.dll
    88KB
  • readmidi.m
    1.5KB
  • keymode.m
    889B
  • ivdirdist1.m
    983B
  • midi2nmat.m
    26.4KB
内容介绍
<link href="style.css" rel="stylesheet"></link> <div class='center-wrapper'> <h1>README: Unsupervised Learning of Fundamental Music Features</h1> <h3>Richard Lange</h3> </div> --- Iterative Sparse Coding ---- The algorithm I implemented is called _Iterative Sparse Coding_ (ISC), and was introduced in a [1996 paper by Olshausen and Field][olshausen]. My corresponding code is `par_iterative_sparse_coding.m`. (It used to be `iterative_sparse_coding.m` but then I added parallelization and stopped updating the old one with other changes). Here is an overview of how the algorithm works: Given a set training images, `I`, learn a set of _basis functions_ (features), ![][phi], that best _sparsely_ reconstruct the original images via linear combination. Here, 'sparseness' refers to the size of the reconstruction weights, ![][alpha]. The number of features to be learned is set by the user beforehand. _Reconstruction_ of image `j` is defined as follows: ![](images/I hat.png) A vector of ![][alpha] is learned for *each* image using the given ![][phi]. The denseness (negative sparseness) of ![][alpha] is defined as ![](images/dense.png) where `S(x)` is a function that is smallest at `x=0`. ![][sigma] is a hyperparameter. The authors proposed three options (the third is the most intuitive, the first two work nicer with math): ![](images/S0.png) ![](images/S1.png) ![](images/S2.png) The algorithm is fairly simple: it minimizes error `E`, defined as a weighted sum of _reconstruction error_ and _denseness_. Reconstruction error for image `j` is simply ![](images/reconstruction error j.png) The error function is, then ![](images/E_toplevel_sumj.png) ![][lambda] is a hyperparameter that controls the relative weight of `R` and `D`. A common question I get when explaining this algorithm is "why does sparseness matter?" My intuition for this is that the fewer features it takes to reconstruct a training example, the more those features defined something fundamental. If this is done for all images, the features then define something fundamental and *shared* between images. The significant result that Olshausen and Field found is that this simple algorithm successfully generates good _convolutional features_ for image processing, despite being defined in terms of _sums_ for reconstruction. This is almost surprising, but makes sense from a mathemagical/intuitive perspective. --- How to run the code --- __main algorithm__ To run the main algorithm or do heavy computations, `ssh` into the [Thayer Computing Cluster](https://wiki.thayer.dartmouth.edu/display/computing/Linux+Services) and run matlab from the command line using `matlab -nodisplay` (most of the scripts that required this heavy parallelization automatically save the results to `saved data/remote`). First, run `init`. After this, you can just use `run` to run the full algorithm with all default options. The following variables can be changed prior to running `run`: * `composers` - cell array of composer names, e.g. `{'joplin', 'debussy', 'beeth'}`. The choices are the names of directories in `midi files`. Default is `{'joplin', 'chopin'}` * `parallel` - a boolean determining whether or not to use parallelization. default is false. * `pool` - number of cores to use in parallelization (used in `matlabpool(pool)`). Only works if `parallel` is true. default is 2 (thayer servers can go up to 8). * `N_HARMONY` - number of times to apply harmony boosting. Default is 0. * `sigma` - A hyperparameter of the model indirectly controlling the learning rate of the weights for each image reconstruction. Default to the average variance of the training images. * `lambda` - A hyperparameter of the model. Lambda controls the priority between reconstruction error and denseness error. * `outer` - max number of outer loops (within each outer loop, it does gradient descent on ![][alpha] in terms of reconstruction then takes one step of gradient descent for ![][phi]. Default is 4000 to 5000. * `inner - max number of iterations for gradient descent on ![][alpha] (usually converges in under 20, but default is 60). * `NUM_IMG_PER_PHI_UPDATE` - As mentioned in the fine print of Olshausen and Field's paper, we don't need to try to reconstruct *all* the images before updating ![][phi]. This parameter controls how many train images to look at per update of ![][phi]. Default is 100. However, I got best results before adding this option in. Might as well set it to `Inf`. Now for actually running it.. Note that, due to some strange parallelization bugs, larger songs can't be loaded in parallel. This can be done separately by calling `get_song_matrices` after specifying `composers`. Here is a typical command line session (on remote server). >> init >> get_song_matrices; % takes a while, but sometimes breaks parallel stuff if the songs are large, so best to do it here >> parallel = true; >> pool = 8; >> outer = 4500; >> NUM_IMG_PER_PHI_UPDATE = Inf; >> run; % this is the part that takes a long time (30 min to 150 min depending on num features, etc..) __test scripts__ The main test script (and the only one that I can guarantee works) is `test_iterative_sparse_encoding.m`. With nothing else specified, this will do the grating test that I presented in the poster presentation; it will generate 25 training images made from the sum of 5 random gratings and run ISC. The other important test is `test_classifier.m`, which uses the results of feature-generation (must have `B_ISC` and `B_PCA` in workspace) and convolves them with small samples of songs from the current composers. Using a hack-y version of n-fold cross validation, it does a bunch of classification trials and plots the results. Note: this was added after the poster presentation and may be buggy. Also the results are inconclusive. __plots__ Open the actual Matlab application and load the saved results. Type `plots=true;` in the command window, then open scripts like `run_ISC`, `run_PCA`, or `test_iterative_sparse_encoding` and run the cells individually to get plots. --- Data format/important variables --- * `song2d_cell` - a cell array containing all 2D song matrices. Each song matrix has pitch on columns and beat on rows. In other words, `song(340:345, 61)=1` sets the note with pitch 61 to be held for 5 beats, probably somewhere in the middle of the song.. * `B_ISC` - cell array of features learned by ISC * `A_ISC` - weight matrix for reconstruction with features `B_ISC`. KxM, where there are K training images and M features. * the above two also will be computed for PCA when you call `run` --- What I did ---- I wrote almost all code from scratch (2114 lines in .m files), except the midi_lib, which I downloaded from [here](https://www.jyu.fi/hum/laitokset/musiikki/en/research/coe/materials/miditoolbox/) and `suplabel.m` (adds a super-title to all subplots), which I downloaded [here](http://www.mathworks.com/matlabcentral/fileexchange/7772-suplabel). I downloaded the midi files from two sources: [ragtime](http://www.trachtman.org/ragtime/) and [classical](http://www.piano-midi.de/midi_files.htm). PATCH_3Darray is a 3D matrix visualization function I downloaded [here](http://www.mathworks.com/matlabcentral/fileexchange/28497-plot-a-3d-array-using-patch). Since I converted from 3D song representations to 2D, I no longer use this. [alpha]: images/alpha.png [phi]: images/phi.png [lambda]: images/lambda.png [sigma]: images/sigma.png [olshausen]: http://www.nature.com/nature/journal/v381/n6583/abs/381607a0.html
评论
    相关推荐
    • 蛙跳算法MATLAB程序
      基本蛙跳算法MATLAB程序。用MATLAB编写的基础算法
    • 遗传算法Matlab程序
      应用数字群算法设计数字滤波器的matlab程序,遗传算法是最近几年流行的优化算法
    • Q算法MATLAB仿真
      移动机器人路径规划MATLAB仿真,使用Q-Learning算法
    • PSO 算法matlab程序
      这个程序就是最基本的粒子群优化算法程序,用Matlab实现。
    • 遗传算法MATLAB应用
      老师上课的参考书 主要是关于遗传算法的一些MATLAB应用,十分有意思 希望大家能喜欢
    • 遗传算法MATLAB实现
      遗传算法MATLAB实现,附WORD说明算法
    • 遗传算法matlab
      matlab程序下的遗传算法
    • 遗传算法matlab
      遗传算法是自然选择和群体学基础上的非数值优化方法。提供了些matlab实例计算
    • 遗传算法matlab
      matlab是科学计算常用的工具,遗传算法也是一种目前比较流行的一种算法,利用matlab写的遗传算法代码,供大家参考。
    • 遗传算法matlab代码
      遗传算法matlab代码,能够正常运行,对于刚开始接触遗传算法的人员有很好的帮助