deeppy icon indicating copy to clipboard operation
deeppy copied to clipboard

Another feature request for `predict`

Open sdemyanov opened this issue 10 years ago • 1 comments

Hi Anders,

Could you also add an option to view the probabilities in 'predict'? I tried to do it by myself:

  1. In class SoftmaxCrossEntropy I changed the function 'fprop' on def fprop(self, x): sm = self._softmax(x) return ca.nnet.one_hot_decode(sm), sm

  2. in class NeuralNetwork I change the function 'predict' to return both predictions and probabilities

  3. in 'test_error()' I read two values: y, yp = net.predict(test_input)

However, I always get an error 'too many values to unpack' for the 'test_error" function, which means that I do not reload it properly. Could you also explain how to do it correctly? Surprisingly I find two sources: in deeppy/deeppy and deeppy/build/lib/deeppy. Moreover, the upstack error appears in '/anaconda/lib/python2.7/site-packages/deeppy-0.1.dev0-py2.7.egg/deeppy/train/sgd.py', in the function 'val_error = val_error_fun()'. Could you clarify these details please?

Regards, Sergey.

sdemyanov avatar Aug 18 '15 08:08 sdemyanov

Hi Sergey!

Just return the probabilities:

def fprop(self, x):
    return self._softmax(x)

I think you should also change the behavior of y_shape() to match the new array size. You can always get the class labels with numpy.argmax(). :)

I should say that I plan on changing the NeuralNetwork interface for more flexibility at test time.

Best, Anders

andersbll avatar Aug 18 '15 08:08 andersbll