# split test and train data v_train, v_test = np.split(v_all, [num_train]) tp_train, tp_test = np.split(tp_all, [num_train]) 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[ ]:
tp_all = tp_all[indices] # split test and train data v_train, v_test = np.split(v_all, [num_train]) tp_train, tp_test = np.split(tp_all, [num_train]) 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[ ]:
label_train = np.empty(0, dtype=np.int32) for i_set in range(n_hold-1): v_train = utils.vstack_(v_train, v_s[set_l[i_set]]) 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]