【发布时间】:2019-11-03 19:43:39
【问题描述】:
数值数据,使用深度学习神经网络。我为此目的使用 Keras 库
p u d ms action B x y-c pre area finger
0 0 36 3 1334893336790 0 1 262 262 262 0.044444 0.0
1 0 36 3 1334893336790 2 1 262 271 0.32 0.044444 0.0
2 0 36 3 1334893336795 2 1 123 327 0.28 0.044444 0.0
3 0 36 3 1334893336800 1 1 123 327 0.28 0.044444 0.0
4 0 36 3 1334893336885 0 1 216 298 0.34 0.044444 0.0
5 0 36 3 1334893336907 2 1 216 298 0.38 0.044444 0.0
6 0 36 3 1334893336926 2 1 147 312 0.60 0.088889 0.0
7 0 36 3 1334893336949 2 1 115 328 0.63 0.044444 0.0
8 0 36 3 1334893336952 2 1 98 336 0.17 0.133333 0.0
9 0 36 3 1334893336971 1 1 98 336 0.17 0.133333 0.0
1 0 36 3 1334893337798 0 1 108 339 0.48 0.044444 0.0
下面的代码可以工作,但是,据我所知,神经网络输入是逐行作为输入的,这里我试图根据 action column 进行输入和输出,如下例所示它以 0 开始并以 1 结束,然后包括第 [0 到 3] 行 3 的神经网络的第一个输入,第二个输入是 [4 到 9] 9 包括在内,依此类推... action列元素代表手部动作,如果值为0表示手的手指按在屏幕上,如果为1则表示手从屏幕上抬起,所以我尝试分成n个笔画,尝试在基于手指压力和提升(行程)的神经网络上进行输入,基于这个想法,输入将从 900k 减少到 20k,但每次输入都是基于多行的
the first input will be as below:
p u d ms action B x y-c pre area finger
0 0 36 3 1334893336790 0 1 262 262 262 0.044444 0.0
1 0 36 3 1334893336790 2 1 262 271 0.32 0.044444 0.0
2 0 36 3 1334893336795 2 1 123 327 0.28 0.044444 0.0
3 0 36 3 1334893336800 1 1 123 327 0.28 0.044444 0.0
and the second input will be :
p u d ms action B x y-c pre area finger
4 0 36 3 1334893336885 0 1 216 298 0.34 0.044444 0.0
5 0 36 3 1334893336907 2 1 216 298 0.38 0.044444 0.0
6 0 36 3 1334893336926 2 1 147 312 0.60 0.088889 0.0
7 0 36 3 1334893336949 2 1 115 328 0.63 0.044444 0.0
8 0 36 3 1334893336952 2 1 98 336 0.17 0.133333 0.0
9 0 36 3 1334893336971 1 1 98 336 0.17 0.133333 0.0
这是我的代码,它在 NN 的正常周期中运行良好,但我试图根据我的想法对其进行更改..
#o = no_of_click
o=0
lenf=len(dataset)
for h in dataset.index[dataset.iloc[:, 4] == 0]:
if dataset.iloc[h+1,4]==1 :
dataset.iloc[h+1,4]=-1
dataset.iloc[h , 4] = -1
o=o+1
dataset=dataset.drop(dataset[dataset.iloc[:, 4] == -1].index)
lenf=(o*2)
X = dataset.iloc[:, 2:].values #here 3to 11 for x
y = dataset.iloc[:, 1].values #here user id 2 only y
binariz = LabelBinarizer()
s = binariz.fit_transform(X[:, 0])
X = np.delete(X, [0], axis=1)
X = np.hstack([s,X])
y = binariz.fit_transform(y)
# X Features scaling
sc_X = StandardScaler()
X = sc_X.fit_transform(X)
# Splitting Data
X_train, X_test,y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)
classifier = Sequential()
# Adding the input layer and the first hidden layer
classifier.add(Dense(units = 50, activation = 'relu', input_dim = X_train.shape[1]))
# Adding the second hidden layer
classifier.add(Dense(units = 50, activation = 'relu'))
# Adding the output layer
classifier.add(Dense(units = y.shape[1], activation = 'softmax'))
# Compiling the ANN
classifier.compile(optimizer = 'adam', loss = 'categorical_crossentropy', metrics = ['accuracy'])
# Fitting the ANN to the Training set
classifier.fit(X_train, y_train, batch_size = 100, epochs = 10)
【问题讨论】:
-
离题 - 我看到你删除了你的 TAP3 问题 - 如果你在未来的某个时候愿意,我仍然很乐意提供帮助。祝你好运!
-
谢谢兄弟,我已经解决了这个问题,所以你是个好人
-
mashro3ak,很高兴听到它!您愿意取消删除您的问题并将您的解决方案作为答案发布吗?这样,它可以帮助可能有类似问题的其他人。 (另外,您可以从对您的问题或答案的投票中获得一些声誉。:))见stackoverflow.com/help/self-answer。当然取决于你! (也谢谢你的好话!)
-
我已经发布了这个问题作为答案;)
标签: numpy tensorflow keras neural-network deep-learning