In [29]:
import cPickle as pickle
import numpy as np
In [38]:
inFile = 'models/test.bin'
phoneFile = 'data/timit_sets.txt'
In [31]:
# read model training history
with open(inFile,'r') as f:
nn_opts = pickle.load(f)
costt = pickle.load(f)
nn_hist = pickle.load(f)
In [47]:
# read phone strings
phone_list = []
with open(phoneFile,'r') as f:
phone_list = map(lambda x: x.rstrip(), f.readlines())
# prepend symbol for blank
phone_list.insert(0,'')
In [32]:
pyplot.plot(costt,'kx')
Out[32]:
In [33]:
k =nn_hist.keys()[0]
In [34]:
# analyze probs after first iteration
cur_prob, cur_delta = nn_hist[k][0]
In [35]:
cur_prob.shape
Out[35]:
In [36]:
key_list = nn_hist.keys()[:3]
In [54]:
# plot a bunch of the training set
for k in key_list:
cur_prob, cur_delta = nn_hist[k][0]
plt.figure()
# Have a look at the colormaps here and decide which one you'd like:
# http://matplotlib.org/1.2.1/examples/pylab_examples/show_colormaps.html
colormap = plt.cm.gist_ncar
plt.gca().set_color_cycle([colormap(i) for i in np.linspace(0, 0.9, 40)])
for p in range(cur_prob.shape[0]):
plt.subplot(2,1,1)
plt.plot(cur_prob[p,:], )
plt.subplot(2,1,2)
plt.plot(cur_delta[p,:], )
# put text for each new argmax phone
plt.subplot(2,1,1)
pmInd = -1
hyp = []
maxInd = np.argmax(cur_prob, axis=0)
for t in range(cur_prob.shape[1]):
if maxInd[t] != pmInd:
pmInd = maxInd[t]
plt.text(t,0.5,phone_list[pmInd])
hyp.append(phone_list[pmInd])
plt.title('-'.join(hyp))
plt.show()
#input('press to continue')
In [55]:
plt.close('all')
In [ ]: