Path: blob/master/notebooks/book2/29/supplementary/hmm_bach_chorales_distrax.ipynb
1193 views
Kernel: Python 3
Bach Chorales
Imports
In [3]:
In [4]:
Load Training Dataset
In [5]:
Out[5]:
Downloading - https://d2hg8soec8ck9v.cloudfront.net/datasets/polyphonic/jsb_chorales.pickle.
Download complete.
(229, 129, 88)
(229, 129, 51)
[129 65 49 65 114 33 57 49 64 33 108 48 49 48 61 48 65 53
41 52 33 61 41 45 69 39 57 80 86 57 61 105 68 65 48 57
57 52 48 33 93 41 65 49 73 48 33 45 65 52 49 109 49 52
65 41 49 65 77 73 57 41 65 57 44 33 85 72 60 41 49 33
56 52 56 83 57 57 52 41 53 64 61 65 65 48 25 96 41 37
76 65 65 72 41 65 41 37 77 48 85 57 72 48 45 53 49 84
68 49 73 50 96 55 66 98 37 76 65 33 49 77 76 65 128 41
45 61 33 88 61 63 65 68 60 49 48 45 65 45 33 64 64 65
49 63 61 48 45 65 84 120 41 102 49 57 69 57 82 48 76 48
52 113 97 83 33 68 41 49 65 109 108 60 65 57 49 33 57 33
61 113 58 64 65 33 57 49 64 68 60 65 41 72 53 49 57 33
49 89 65 44 49 61 65 69 52 76 33 57 76 57 33 76 101 40
41 44 76 65 49 54 49 49 64 51 109 65 65]
Present Notes
In [6]:
Out[6]:
[22 25 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
73 74 75]
Visualization of Training Sequences
In [7]:
Out[7]:
Gradient Descent Implementation
Creates mini-batches.
In [8]:
In [9]:
Initialize HMM
In [10]:
Model Selection
Determine Hyperparameters
In [11]:
In [32]:
In [33]:
In [34]:
Out[34]:
Visualization of Parameters of HMM
In [19]:
In [20]:
In [21]:
Observation Distribution
In [22]:
Out[22]:
Transition Probabilities
In [23]:
In [24]:
Out[24]:
Model Selection
Load Test Dataset
In [25]:
In [26]:
In [27]:
Out[27]:
Best Model
In [28]:
In [29]:
Out[29]:
Best Model : batch_size=20, K=24
Test Negative Loglikelihood of Best Model : 8.054402351379395
Visualization of Parameters of the Best HMM
Observation Distribution
In [30]:
Out[30]:
Transition Probabilities
In [31]:
Out[31]: