简体   繁体   English

CNN模型的预测

[英]Prediction on CNN model

I am trying to do a model to recognize one human movement. 我正在尝试建立一个模型来识别人类的动作。 My activity is to recognize a person catching. 我的活动是认识一个被捉住的人。 I already have a record with about 260 right movements and I annoted that file with labels "catch" and "nothing" to train my model. 我已经有大约260次正确移动的记录,并且为该文件添加了标签“ catch”和“ nothing”以训练模型。 I have another file, this file is annoted too, just to test the accuracy of the model. 我还有另一个文件,这个文件也有注释,只是为了测试模型的准确性。

I am using a CNN model based on this site . 我正在基于此站点使用CNN模型。 And I modified the window size to 400 (equivalent of 4s of record) So after trainning my model I have this results (my model is saved and is already trained from a previous record, that's why it gives good results in the first epochs): 然后我将窗口大小修改为400(相当于记录的4s),因此,在训练完模型后,我得到了以下结果(我的模型已保存,并且已经从以前的记录中进行了训练,这就是为什么在第一个时期可以得到良好结果的原因):

Epoch:  0  Training Loss:  0.5428493594505138  Training Accuracy:  0.99394274

Epoch:  1  Training Loss:  0.5227164919283446  Training Accuracy:  0.99394274

Epoch:  2  Training Loss:  0.5037865922760709  Training Accuracy:  0.99449337

Epoch:  3  Training Loss:  0.4860136515261339  Training Accuracy:  0.99614537

Testing Accuracy: 0.5686275 测试准确度:0.5686275

My code to train is: 我要训练的代码是:

for epoch in range(training_epochs):
        cost_history = np.empty(shape=[1], dtype=float)
        for b in range(total_batchs):
            offset = (b * batch_size) % (train_y.shape[0] - batch_size)
            batch_x = train_x[offset:(offset + batch_size), :, :, :]
            batch_y = train_y[offset:(offset + batch_size), :]
            _, c = session.run([optimizer, loss], feed_dict={X: batch_x, Y: batch_y})
            cost_history = np.append(cost_history, c)
            print("Epoch: ", epoch, " Training Loss: ", np.mean(cost_history), " Training Accuracy: ",                session.run(accuracy, feed_dict={X: train_x, Y: train_y}))
        print("Testing Accuracy:", session.run(accuracy, feed_dict={X: test_input, Y: test_labels}))

After that, I wanna predict some results whit this: 之后,我想预测一些结果:

prediction = session.run(y_, feed_dict={X: predict_input})

But the results were: 但是结果是:

[[7.6319778e-04 9.9923682e-01]

 [3.3351363e-04 9.9966645e-01]

 [2.5510782e-04 9.9974483e-01]

...

 [2.5133172e-04 9.9974865e-01]

 [2.4705922e-04 9.9975294e-01]

 [3.0652966e-04 9.9969351e-01]

 [1.5634180e-04 9.9984360e-01]]

Questions at Hand: 手头的问题:

  • Am I doing something wrong? 难道我做错了什么?
  • Shouldn't the values of the predictions be higher values like [0.80 0.20]? 预测的值不应该是较高的值,例如[0.80 0.20]吗?
  • The window size is good with 400? 窗口大小是否适合400?
  • In prediction each line corresponds to a window size of data am I right? 在预测中,每行对应于数据的窗口大小,对吗?

Clarifying range of prediction values 明确预测值范围

as I see it, your values are 0.007 and 0.993 or something in that Magnitude - so what exactly do you mean by higher, since the sum is always 1. So if one gets higher the other should get smaller - if I understood your Problem correctly. 如我所见,您的值分别为0.007和0.993或该幅度中的某个值-那么您的确切含义是更高,因为总和始终为1。因此,如果一个值变高,另一个应该变小-如果我正确理解了您的问题。

Clarifying prediction correspondance 澄清预测对应

Since you labeled your data with the classes "catch" and "nothing" that's what your predictions correspond to. 由于您使用“ catch”和“ nothing”类标记了数据,这就是您的预测所对应的。 So an Output of (0, 1) would mean that your Network predicts the Input to be of the second class. 因此,输出(0,1)表示您的网络预测输入为第二类。

Clarifying window size 澄清窗口大小

To solve this I first Need you to explain, what you mean by window size. 为了解决这个问题,我首先需要您解释一下,窗口大小是什么意思。 The amount of recorded seconds that you use as an input? 您用作输入的记录秒数? If so, I would say, that if you can recognize a "catch" within this time Frame - then your Network should also be able to do so. 如果是这样,我想说的是,如果您可以在此时间范围内识别出“渔获物”,那么您的网络也应该能够做到。 Other than that, this would be an appropriate case for a line search. 除此之外,这对于行搜索是合适的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM