[array([2,1,2,0]),array(['10_c.jpg','10_m.jpg','10_n.jpg','1_c.jpg','1_m.jpg','1_n.jpg','2_c.jpg','2_m.jpg','2_n.jpg','3_c.jpg','3_m.jpg','3_n.jpg','4_c.jpg','4_m.jpg','4_n.jpg','5_c.jpg','5_m.jpg','5_n.jpg','6_c.jpg','6_m.jpg','6_n.jpg','7_c.jpg','7_m.jpg','7_n.jpg','8_c.jpg','8_m.jpg','8_n.jpg','9_c.jpg','9_m.jpg','9_n.jpg'],dtype='<U15'),array([[255,252,255,...,255],[136,137,138,114,110,111],[200,200,199,179,178,177],[146,157,165,202,201],[228,225,222,219,221,223],[128,127,133,129,127]])]
每批包含所有图像,并运行30个epohs:
EPOCH 00 0.476923DONE WITH EPOCHEPOCH 10 0.615385DONE WITH EPOCHEPOCH 20 0.615385DONE WITH EPOCHEPOCH 30 0.538462DONE WITH EPOCHEPOCH 40 0.384615DONE WITH EPOCH......EPOCH 280 0.615385DONE WITH EPOCHEPOCH 290 0.692308DONE WITH EPOCH
我的问题是我想尝试新的图像(测试),并想知道返回的类(0,2).在这种情况下我该怎么办?换句话说,我训练了CNN,但是如何测试呢?
编辑-1
对于评估准确度点,我在测试20张图像时得到以下结果:
EPOCH 00 1.0DONE WITH EPOCHEPOCH 10 1.0DONE WITH EPOCHEPOCH 20 1.0DONE WITH EPOCHEPOCH 30 1.0DONE WITH EPOCHEPOCH 40 1.0DONE WITH EPOCHEPOCH 50 1.0DONE WITH EPOCHEPOCH 60 1.0DONE WITH EPOCHEPOCH 70 1.0DONE WITH EPOCHEPOCH 80 1.0DONE WITH EPOCHEPOCH 90 1.0DONE WITH EPOCHEPOCH 100 1.0DONE WITH EPOCHEPOCH 110 1.0DONE WITH EPOCHEPOCH 120 1.0DONE WITH EPOCHEPOCH 130 1.0DONE WITH EPOCHEPOCH 140 1.0DONE WITH EPOCHEPOCH 150 1.0DONE WITH EPOCHEPOCH 160 1.0DONE WITH EPOCHEPOCH 170 1.0DONE WITH EPOCHEPOCH 180 1.0DONE WITH EPOCHEPOCH 190 1.0DONE WITH EPOCHEPOCH 200 1.0DONE WITH EPOCHEPOCH 210 1.0DONE WITH EPOCHEPOCH 220 1.0DONE WITH EPOCHEPOCH 230 1.0DONE WITH EPOCHEPOCH 240 1.0DONE WITH EPOCHEPOCH 250 1.0DONE WITH EPOCHEPOCH 260 1.0DONE WITH EPOCHEPOCH 270 1.0DONE WITH EPOCHEPOCH 280 1.0DONE WITH EPOCHEPOCH 290 1.0DONE WITH EPOCH
在应用获取网络为测试数据生成的标签时,我得到以下内容:
EPOCH 00 0.0DONE WITH EPOCHEPOCH 10 0.0DONE WITH EPOCHEPOCH 20 0.0DONE WITH EPOCHEPOCH 30 0.0DONE WITH EPOCHEPOCH 40 0.0DONE WITH EPOCHEPOCH 50 0.0DONE WITH EPOCHEPOCH 60 0.0DONE WITH EPOCHEPOCH 70 0.0DONE WITH EPOCHEPOCH 80 0.0DONE WITH EPOCHEPOCH 90 0.0DONE WITH EPOCHEPOCH 100 0.0DONE WITH EPOCHEPOCH 110 0.0DONE WITH EPOCHEPOCH 120 0.0DONE WITH EPOCHEPOCH 130 0.0DONE WITH EPOCHEPOCH 140 0.0DONE WITH EPOCHEPOCH 150 0.0DONE WITH EPOCHEPOCH 160 0.0DONE WITH EPOCHEPOCH 170 0.0DONE WITH EPOCHEPOCH 180 0.0DONE WITH EPOCHEPOCH 190 0.0DONE WITH EPOCHEPOCH 200 0.0DONE WITH EPOCHEPOCH 210 0.0DONE WITH EPOCHEPOCH 220 0.0DONE WITH EPOCHEPOCH 230 0.0DONE WITH EPOCHEPOCH 240 0.0DONE WITH EPOCHEPOCH 250 0.0DONE WITH EPOCHEPOCH 260 0.0DONE WITH EPOCHEPOCH 270 0.0DONE WITH EPOCHEPOCH 280 0.0DONE WITH EPOCHEPOCH 290 0.0DONE WITH EPOCH
为什么我得到0或1?这些值是否有意义(即没有分数)?
编辑-2
为了获取网络为测试数据生成的标签,在打印出标签值和每个时期的准确性时,我得到以下内容(标签总是0,虽然我只期望0或2,准确度为1) :
EPOCH 0[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 1.0DONE WITH EPOCHEPOCH 1[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 1.0DONE WITH EPOCHEPOCH 2[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 1.0DONE WITH EPOCHEPOCH 3[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 1.0DONE WITH EPOCHEPOCH 4[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 1.0DONE WITH EPOCHEPOCH 5[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 1.0DONE WITH EPOCH..........EPOCH 28[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 1.0DONE WITH EPOCHEPOCH 29[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 1.0DONE WITH EPOCH
谢谢.
解决方法 一般讨论;一般交流通常,为了测试神经网络,您需要获取未用于训练的新标记数据,在此数据上应用网络(即应用前馈过程),并评估结果的准确性(与你知道的真实标签相比).
如果您没有这样的新数据(也就是说,如果您使用了所有数据进行培训)并且无法生成新数据,我建议您将您的培训数据与培训和测试分开,然后重新运行培训程序从一开始就对训练数据.重要的是,测试数据将是未使用的数据,以便能够评估模型的性能.
评估准确性
现在,假设您从this问题谈论网络,
您可以执行类似的 *** 作来衡量测试数据的准确性:
accuracy_test = sess.run(accuracy,Feed_dict={x: test_data,y: test_onehot_vals})
其中test_data和test_onehot_vals是您的测试图片(和相应的标签).
回想一下,对于培训,您运行以下内容:
_,accuracy_val = sess.run([train_op,accuracy],Feed_dict={x: batch_data,y: batch_onehot_vals})
请注意,我在precision_test的评估中没有使用train_op.这是因为当你测试你的表现时,你不会优化权重或类似的东西(train_op会做什么).您只需应用当前拥有的网络即可.
获取网络为测试数据生成的标签
最后,如果您需要测试数据的实际标签,则需要获取tf.argmax(model_op,1)的值.因此,您可以将其设置为单独的变量,例如在行的正上方
correct_pred = tf.equal(tf.argmax(model_op,1),tf.argmax(y,1))
你可以做:
res_model=tf.argmax(model_op,1)correct_pred = tf.equal(res_model,1))
然后将其与accuracy_test一起评估,如下所示:
res,accuracy_test = sess.run([res_model,y: test_onehot_vals}).
在未标记的数据上应用网络
在完成网络测试后,假设您对结果感到满意,您可以继续并在新的和未标记的数据上应用网络.例如通过做
res_new = sess.run(res_model,Feed_dict = {x:new_data}).
请注意,为了生成res_model(这基本上意味着只在输入上应用网络),您不需要任何标签,因此您在Feed_dict中不需要y值. res_new将是新标签.
总结以上是内存溢出为你收集整理的Python / Tensorflow – 我已经训练了卷积神经网络,如何测试它?全部内容,希望文章能够帮你解决Python / Tensorflow – 我已经训练了卷积神经网络,如何测试它?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)