batchsize = 100
n_epoch = 300


# In[ ]:

# create SdA
n_hiddens = (12**2*num_frame, 6**2*num_frame)
sda = StackedDenoisingAutoencoder(num_pxmovie, n_hiddens)
sda.train(v_all, n_epoch=n_epoch)
sda.save('history', n_hiddens, n_epoch, batchsize)
# sda.load('history/SdA_layer(576, 64)_epoch300.pkl')

# split test and train data
yA_each = sda.predict(v_all, bAllLayer=True)
yA_all = yA_each[-1]
# yA_hidden1_all = yA_each[0]
yA_train, yA_test = np.split(yA_all, [num_train])

# check output histgram
dummy = plt.hist(np.reshape(yA_all, (-1, 1)), 50)


# In[ ]:

## draw weight
def draw_weight(data, size):
    Z = data.reshape(size).T
    plt.imshow(Z, interpolation='none')
    plt.xlim(0,size[0])
Beispiel #2
0
xA_train, xA_test = np.split(xA_all, [num_train])

batchsize = 100
n_epoch = 300

# In[ ]:

# create SdA
n_hiddens = (12**2 * num_frame, 6**2 * num_frame)
sda = StackedDenoisingAutoencoder(num_pxmovie, n_hiddens)
sda.train(v_all, n_epoch=n_epoch)
sda.save('history', n_hiddens, n_epoch, batchsize)
# sda.load('history/SdA_layer(576, 64)_epoch300.pkl')

# split test and train data
yA_each = sda.predict(v_all, bAllLayer=True)
yA_all = yA_each[-1]
# yA_hidden1_all = yA_each[0]
yA_train, yA_test = np.split(yA_all, [num_train])

# check output histgram
dummy = plt.hist(np.reshape(yA_all, (-1, 1)), 50)

# In[ ]:


## draw weight
def draw_weight(data, size):
    Z = data.reshape(size).T
    plt.imshow(Z, interpolation='none')
    plt.xlim(0, size[0])
Beispiel #3
0
     x_train = utils.vstack_(x_train, x_s[set_l[i_set]])
     label_train = utils.vstack_(label_train, label_x_s[set_l[i_set]])
 
 v_train = np.reshape(v_train, (num_train_movie, -1))
 x_train = np.reshape(x_train, (num_train_movie, -1))
 label_train = np.reshape(label_train, (num_train_dataset, -1))
 v_test = np.reshape(v_s[i], (num_test_movie, -1))
 x_test = np.reshape(x_s[i], (num_test_movie, -1))
 label_test = label_x_s[i]
 
 # create SdA
 sda = StackedDenoisingAutoencoder(num_pxmovie, n_hiddens, n_epoch=n_epoch_SdA, use_cuda=use_cuda)
 sda.train(v_train)
 
 # split test and train data
 y_train_each = sda.predict(v_train, bAllLayer=True)
 y_test_each = sda.predict(v_test, bAllLayer=True)
 
 list_layer = []
 for j in range(num_layers):
     y_train  = y_train_each[j]
     y_test   = y_test_each[j]
     
     # separate x&y into other and self
     x_test_split = [np.empty(0,dtype=np.float32), np.empty(0,dtype=np.float32)]
     y_test_split = [np.empty(0,dtype=np.float32), np.empty(0,dtype=np.float32)]
     for i_test in range(int(num_test_movie)):
         label = label_test[i_test//n_onemovie]
         x_test_split[label] = utils.vstack_(x_test_split[label], x_test[i_test])
         y_test_split[label] = utils.vstack_(y_test_split[label], y_test[i_test])