Hi all, Is it possible to implement using Theano an equivalent code to the one below that uses label_binarize from scikit-learn? I need the assert of the following code to be True.
import numpy as np > from theano import tensor as T > from sklearn.preprocessing import label_binarize p = np.array([[.0, 1., 1.], [1., 1., 0.]]) > q = np.array([[.3, .1, .6], [.7, .2, .1]]) > o_t = label_binarize(np.argmax(np.multiply(p, q), axis=-1), > range(p.shape[-1])) # <--- desired result > o_n = T.argmax(T.mul(p, q), axis=-1, keepdims=True).eval() # <--- modify > this line > np.allclose(o_t, o_n) However, the problem is that it needs to be in a loss function that will be passed to Keras, for that reason I can not use label_binarize as I am defining the loss function with tensors and not Numpy arrays. def osl_brier_loss(y, p): > d = T.argmax(T.mul(y, p), axis=-1, keepdims=True) > return T.mean(T.square(T.sub(p, d))) I hope somebody can point me to some tutorial or code that I can use to solve this task. Thanks in advance! Miquel -- --- 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.
