1.打乱数据
def _shuffle(X, Y):
# This function shuffles two equal-length list/array, X and Y, together.
randomize = np.arange(len(X))
np.random.shuffle(randomize)
return (X[randomize], Y[randomize])
2.划分小批量训练数据
# Mini-batch training
for idx in range(int(np.floor(train_size / batch_size))):
X = X_train[idx*batch_size:(idx+1)*batch_size]
Y = Y_train[idx*batch_size:(idx+1)*batch_size]
3.选取前n个最重要的数据标签
ind = np.argsort(np.abs(w))[::-1]
features = np.array(content)
for i in ind[0:10]:
print(features[i], w[i])