Question 1. 

Where the class ConvPoolLAyer is defined, you can see that params is: 
self.params 
= [self.W, self.b]

To save that params you just have to get the values: 

w0_test = layer0.W.get_value()
b0_test = layer0.b.get_value()

w1_test = layer1.W.get_value()
b1_test = layer1.b.get_value()

w2_test = layer2.W.get_value()
b2_test = layer2.b.get_value()


or


params_layer0 = layer0.params.get_value()


You can not get the value where the class is being defined, you need to do that 
in ''evaluate_lenet()'' , in the training or in the testing.



To assign the params you just have to set the value in the same way that you 
have gotten:


layer0.W.set_value(w0_test)
layer0.b.set_value(b0_test)

layer1.W.set_value(w1_test)
layer1.b.set_value(b1_test)

layer2.W.set_value(w2_test)
layer2.b.set_value(b2_test)


or


layer0.params.set_value(params_layer0)



and then just have to test (for example, or train or whatever):


for i in range(n_test_batches):
    print i
    test_losses = [test_model(i)]
    test_score = numpy.mean(test_losses)



3. The class prediction is all the time being predicted independing of the 
batch size, the batch size is just for reading images in group and save 
memory. You can have the prediction regardless of the batch size. To get 
the prediction you need to create a theano function as the same way if you 
would loke to get weights or bias.

If you go through logistic regresion (that is the classifier, so that is 
where the prediction is going to be done) python file you can see in class 
LogisticRegression(object): that there are a y_pred, that is you 
prediction. if you have a batch size of 20 images, you would get 20 
preictions, if you have a batch size of 50, fifty predictions. To get that 
value 

I hope I've helped


El lunes, 26 de septiembre de 2016, 9:31:25 (UTC+2), Mallika Agarwal 
escribió:
>
> I scoured the internet and I can see that this question has been asked by 
> many users, but I'm still unable to understand how to do this. 
>
> I have a simple network (as given in the CNN tutorial 
> <http://deeplearning.net/tutorial/lenet.html>), except modified to work 
> on 100*100 images, and a smaller dataset. 
>
> This is basically 
>
>    1. LeNetConvPoolLayer
>    2. LeNetConvPoolLayer
>    3. HiddenLayer
>    4. LogisticRegression (outputs a 0 or 1). 
>
> *1. (Logistically) How do I save the parameters? Do I save them for each 
> of the layers or do I simply save the shared variable "params"*?
> params = layer3.params + layer2.params + layer1.params + layer0.params
>
> *2. Once saved, do I have to reconstruct this network in another script 
> using these params? If so, how do I use these params? I can't find any line 
> which assigns the params anywhere.* 
>
> I would like to have the predicted class and the confidence of the 
> prediction, to be able to perform verification for face recognition. 
>
>
>
> *3. If I want to predict the class for every image, do I simply change the 
> batch size to 1? Where can I actually print this prediction? There is a 
> function call*
> test_losses = [
>                     test_model(i)
>                     for i in range(n_test_batches)
>                 ]
>
> *which is defined before as *
>
> # create a function to compute the mistakes that are made by the model
>     test_model = theano.function(
>         [index],
>         layer3.errors(y),
>         givens={
>             x: test_set_x[index * batch_size: (index + 1) * batch_size],
>             y: test_set_y[index * batch_size: (index + 1) * batch_size]
>         }
>     )
>
> *I can't understand where the class is actually being predicted/which 
> variable it is stored in. *
>
>
> If anyone could help me out with even one of these questions, I'd be 
> *extremely* grateful! 
> Please let me know if I could provide any other info. 
>
>  
>

-- 

--- 
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