# HG changeset patch # User Chris Cannam # Date 1396282911 -3600 # Node ID cd9fd74931bb0fbf7d384a2f35ccde7cc3dd6d91 # Parent 9ec18d453889b738ce572e7009b3e34b136de91e Reuse some calculations, plot some plots diff -r 9ec18d453889 -r cd9fd74931bb yeti/em.yeti --- a/yeti/em.yeti Mon Mar 31 17:06:24 2014 +0100 +++ b/yeti/em.yeti Mon Mar 31 17:21:51 2014 +0100 @@ -83,18 +83,23 @@ columns = mat.width chunk; e = mat.constMatrix epsilon { rows = 1, columns }; + noteInstrumentProducts = [:]; + pitches = mat.concatVertical (map do note: if note < data.lowest or note > data.highest then e else fold do acc inst: { w, p, s } = distributionsFor data inst note; - fold do acc bin: - mat.sum - [acc, - mat.scaled (mat.at w bin 0) - (mat.entryWiseProduct - [p, s, mat.newRowVector (mat.getRow bin chunk)])] - done acc [0..mat.height chunk - 1] + prod = + fold do acc bin: + mat.sum + [acc, + mat.scaled (mat.at w bin 0) + (mat.entryWiseProduct + [p, s, mat.newRowVector (mat.getRow bin chunk)])] + done e [0..mat.height chunk - 1]; + noteInstrumentProducts[{inst,note}] := prod; + mat.sum [acc, prod]; done e [0..data.nInstruments-1] fi; done [0..data.nNotes - 1]); @@ -105,14 +110,7 @@ (mat.concatVertical (map do note: if not inRange data.ranges inst note then e else - { w, p, s } = distributionsFor data inst note; - fold do acc bin: - mat.sum - [acc, - mat.scaled (mat.at w bin 0) - (mat.entryWiseProduct - [p, s, mat.newRowVector (mat.getRow bin chunk)])] - done e [0..mat.height chunk - 1] + noteInstrumentProducts[{inst,note}] fi done [0..data.nNotes - 1])) done [0..data.nInstruments-1]); diff -r 9ec18d453889 -r cd9fd74931bb yeti/silvet.yeti --- a/yeti/silvet.yeti Mon Mar 31 17:06:24 2014 +0100 +++ b/yeti/silvet.yeti Mon Mar 31 17:21:51 2014 +0100 @@ -5,7 +5,6 @@ { loadTemplates, extractRanges } = load templates; em = load em; -em1 = load em_onecolumn; mat = load may.matrix; vec = load may.vector; @@ -44,7 +43,9 @@ eprintln "we have \(length chunks) chunks of size \(mat.size (head chunks))"; oneIteration emdata chunk n = - ({ estimate, q } = em.performExpectation emdata chunk; + (eprintln "E"; + { estimate, q } = em.performExpectation emdata chunk; + eprintln "M"; newdata = em.performMaximisation emdata chunk q; if (n % 6 == 0) then \() (plot.plot [ Grid chunk ]); @@ -60,7 +61,10 @@ d := oneIteration d (head chunks) i; done; -eprintln "done"; +eprintln "done, plotting pitch activation matrix"; + +\() (plot.plot [Grid d.pitches]); +\() (plot.plot [Contour d.pitches]); (); diff -r 9ec18d453889 -r cd9fd74931bb yeti/silvet_onecolumn.yeti --- a/yeti/silvet_onecolumn.yeti Mon Mar 31 17:06:24 2014 +0100 +++ b/yeti/silvet_onecolumn.yeti Mon Mar 31 17:21:51 2014 +0100 @@ -26,7 +26,7 @@ em1data = em1.initialise ranges templates 88; -col = head (drop 50 columns); // (drop ((length columns) / 2) columns); +col = head (drop 50 columns); \() (plot.plot [ Caption "Source frequency distribution", Vector col ]);