In theano, "for" can be subsititued by "scan", and it worked!

        true_pos, _ = theano.scan(fn = lambda nx, y, y_pred, mask: 
(tensor.eq(y, nx)*tensor.eq(y_pred, nx)*mask).sum(),
                            outputs_info = None,
                            non_sequences = [y, y_pred, mask],
                            sequences = tensor.arange(n_labels))
        false_pos, _ = theano.scan(fn = lambda nx, y, y_pred, mask:\
                                                                
(tensor.neq(y, nx)*tensor.eq(y_pred, nx)*mask).sum(),\
                              outputs_info = None,
                              non_sequences = [y, y_pred, mask],
                              sequences = tensor.arange(n_labels))
        false_neg, _ = theano.scan(fn = lambda nx, y, y_pred, mask: 
(tensor.eq(y, nx)*tensor.neq(y_pred, nx)*mask).sum(),
                              outputs_info = None,
                              non_sequences = [y, y_pred, mask],
                              sequences = tensor.arange(n_labels))

My task is sequence labeling, like multi_class classification, so, 
        r = ((true_pos+0.01) /( true_pos + false_pos+0.02)).mean()
        p = ((true_pos+0.01) /(true_pos + false_neg+0.02)).mean()
        f1 = 2*r*p/(r+p)

在 2015年5月12日星期二 UTC+8下午1:35:09,Mehdi写道:
>
> Hi,
>
> I adapted the code in this 
> <https://github.com/Newmu/Theano-Tutorials/blob/master/3_net.py>page and 
> I need to calculate the precision, accuracy, and recall of my model. I 
> assume np.mean(np.argmax(teY, axis=1) == predict(teX)) calculates the 
> accuracy of the model. Not sure how to calculate the recall and percision. 
> Any help is appreciated. 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to