def get_data(): person_name = ["bear", "rabbit", "haha"] dirname = "jsondata" epochs = 50 offset = "none" data = load(dirname + '/bear_data.npy') labels = load(dirname + '/bear_labels.npy') c = np.array(np.full(data.shape[0], 0)) labels = np.vstack((labels, c)) for i in range(2): a = load(dirname + '/' + person_name[i + 1] + '_data.npy') b = load(dirname + '/' + person_name[i + 1] + '_labels.npy') c = np.array(np.full(a.shape[0], i + 1)) b = np.vstack((b, c)) data = np.vstack((data, a)) labels = np.hstack((labels, b)) a = data print(labels) # print(pre.make_velocity(data).shape) # data = np.concatenate((data,pre.make_offset(a)),axis=2) data = np.concatenate((data, pre.make_velocity(a)), axis=2) # data = np.concatenate((data,pre.make_accel(a)),axis=2) # print(data.shape) data_test = data[np.where(labels[0, :] == 5), :, :, :] data = data[np.where(labels[0, :] <= 2), :, :, :] data_test = data_test.reshape(data_test.shape[1], data_test.shape[2], data_test.shape[3] * data_test.shape[4]) data = data.reshape(data.shape[1], data.shape[2], data.shape[3] * data.shape[4]) print(data.shape) # labels = keras.utils.to_categorical(labels) # print(labels) labels_test = labels[:, np.where(labels[0, :] == 5)] labels = labels[:, np.where(labels[0, :] <= 2)] labels_test = labels_test.reshape(labels_test.shape[0], labels_test.shape[2]) labels = labels.reshape(labels.shape[0], labels.shape[2]) index = np.arange(data.shape[0]) np.random.shuffle(index) data = data[index] labels[0] = labels[0][index] labels[1] = labels[1][index] # print(keras.utils.to_categorical(labels[0])) # print(keras.utils.to_categorical(labels[1])) labels_v = keras.utils.to_categorical(labels[0], num_classes=6) labels = keras.utils.to_categorical(labels[1], num_classes=3) print(labels_v) print(labels) labels_test = keras.utils.to_categorical(labels_test[1], num_classes=3) return data, data_test, labels, labels_test, labels_v
plt.scatter(X_norm[i, 0], X_norm[i, 1], c=cValue[y[i]], alpha=0.7) plt.show() if __name__ == '__main__': filename = 'gym_6kind_012_5_' action_start = 0 X_train = load(filename + "data.npy") Y_train = load(filename + "labels.npy") Y_p_train = load(filename + "labels_p.npy") X_test = load(filename + "data_test.npy") Y_test = load(filename + "labels_test.npy") Y_p_test = load(filename + "labels_p_test.npy") tmp = pre.make_velocity(X_train) X_train = np.concatenate((X_train, tmp), axis=-1) tmp = pre.make_velocity(X_test) X_test = np.concatenate((X_test, tmp), axis=-1) #X_train = pre.make_velocity(X_train) #X_test = pre.make_velocity(X_test) GAN0 = distanglingGAN() GAN0.train(X_train, Y_train, Y_p_train, X_test, Y_test, Y_p_test, action_start, n_batch=3000,
'./data/json_data/action/json_data_seperate/json_data_seperate_senior/data.npy' ) #angle = pre.make_angle(data) data_test = load( './data/json_data/action/json_data_seperate/json_data_seperate_senior/data_test.npy' ) #angle_test = pre.make_angle(data_test) labels = load( './data/json_data/action/json_data_seperate/json_data_seperate_senior/labels.npy' ) labels_test = load( './data/json_data/action/json_data_seperate/json_data_seperate_senior/labels_test.npy' ) #data = pre.make_offset(data) #data_test = pre.make_offset(data_test) data = pre.make_velocity(data) data_test = pre.make_velocity(data_test) index = np.arange(data.shape[0]) np.random.shuffle(index) data = data[index] labels = labels[index] data = data.reshape(data.shape[0], data.shape[1], data.shape[3] * data.shape[2]) data_test = data_test.reshape(data_test.shape[0], data_test.shape[1], data_test.shape[3] * data_test.shape[2]) #mix_data = mix_data.reshape(mix_data.shape[0],mix_data.shape[1],mix_data.shape[2]*mix_data.shape[3]) # data /= 3000 # data_test /= 3000 # data,data_test,labels,labels_test = train_test_split(data,labels,test_size = 0.2,random_state = 10)