In [10]:
# coding: utf-8

# In[ ]:

import math
import pickle

from PIL import Image
import numpy as np

import matplotlib.pyplot as plt
import matplotlib.mlab as mlab

# In[ ]:

## load data
opened   = open('save.dump','rb')
data_all = pickle.load(opened)
#print(data_all.shape)

n_hold    = len(data_all)
num_layers= len(data_all[0])

for i_h in range(num_layers):
    # prepare for plot   1:self, 0:other
    err_other = np.empty(0)
    err_self  = np.empty(0)
    for k_hold in range(n_hold):
        err_other = np.append(err_other, data_all[k_hold][i_h]['hist']['other'])
        err_self  = np.append(err_self,  data_all[k_hold][i_h]['hist']['self'] )
    
    # plot err_eopch
    k_hold = 0
    plt.figure(i_h+100)
    x_other = np.r_[0:data_all[k_hold][i_h]['loss']['other'].shape[0]]
    x_self  = np.r_[0:data_all[k_hold][i_h]['loss']['self'].shape[0]]
    plt.plot(x_other, data_all[k_hold][i_h]['loss']['other'], color = "blue")
    plt.plot(x_self,  data_all[k_hold][i_h]['loss']['self'],  color = "red")
    
    # plot histgram
    plt.figure(i_h)
    plt.hist(err_other, label = "other", normed = True, bins = 20, alpha = 0.5, color = "blue")
    plt.hist(err_self,  label = "self", normed = True,  bins = 20,  alpha = 0.5, color = "red")
    plt.legend()
    print('mean of self error : ' + str(err_self.mean()))
    print('mean of other error : ' + str(err_other.mean()))
    
    data_all[0][i_h]['lastpredict']['label'].reshape(-1)
    data_all[0][i_h]['lastpredict']['pedict'].reshape(-1)
    print()
    print(data_all[0][i_h]['lastpredict']['pedict'])

plt.show()

print('finish!')


mean of self error : 0.0133408887918
mean of other error : 0.0145549442752

[[1]
 [1]
 [1]
 ..., 
 [1]
 [1]
 [1]]
mean of self error : 0.00313126485846
mean of other error : 0.00429245169341

[[1]
 [1]
 [1]
 ..., 
 [1]
 [1]
 [1]]
mean of self error : 0.00205958812992
mean of other error : 0.00439805232787

[[1]
 [1]
 [1]
 ..., 
 [1]
 [1]
 [1]]
finish!

In [9]:
data_all[0][i_h]['lastpredict']['pedict'].reshape(-1)


Out[9]:
(1010,)

In [ ]: