如何在不循环数据的每个元素的情况下计算此精度?

我使用for循环来计算y_pred和y_true之间的精度,这使我的代码非常慢,因此我想避免这种for循环。如何更改此代码?

sumacc =  tf.Variable(0,dtype=tf.float32)
for i in range(0,y_pred_batch_size):
    ele_y_pred = y_pred[i,0:label_length[i,0]]
    ele_y_true = y_true[i,0]]
    sumacc =  sumacc + tf.reduce_mean(tf.cast(tf.equal( ele_y_pred,ele_y_true),tf.float32)) 
tf.print("\n","accuracy: ",sumacc / tf.constant(y_pred_batch_size,dtype=tf.float32) * 100,"%" )

y_pred和y_true的值看起来像.. [batch_index,[[45],[56],[12],...]

chenzhao5001 回答:如何在不循环数据的每个元素的情况下计算此精度?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3164993.html

大家都在问