Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why f = 6 in cnnmnist.py? #22

Closed
cyckun opened this issue Apr 15, 2021 · 2 comments
Closed

why f = 6 in cnnmnist.py? #22

cyckun opened this issue Apr 15, 2021 · 2 comments

Comments

@cyckun
Copy link

cyckun commented Apr 15, 2021

Hi, I'm leaning mpyc, in demo cnnmnist.py, the para f=6, and force python integer to secnum,
scale = lambda a: secnum(int(round(a * f))) # force Python integers;
why f is set to 6? I test f = 1, 2, the demo also work fine.

@cyckun cyckun closed this as completed Apr 15, 2021
@cyckun cyckun reopened this Apr 15, 2021
@lschoe
Copy link
Owner

lschoe commented Apr 15, 2021

Yeah, indeed, the demo will still work in many cases, but the error rate will go up overall if you take small values for f.

The variable f controls the precision used for the CNN parameters (neuron weights and bias for all layers) of the trained network. For f=6 we get the minimum error rate for the MNIST dataset (around 9915 out of 10000 correct). For f=4 the error rate will also be below 1%, but for f=2 the error rate will be around 25% and for f=1 it should be really high.

To see this, it's best if you run the demo with a (random) batch of say 25 samples, like this:

`python cnnmnist.py 25`

This will also run faster than 25 individual runs because some of the costs are amortized (like loading and converting the weights of the trained network, especially for layer 3 which has 12 MB of weights, see mpyc/demos/data/cnn).

Now you should see more errors for f=2 and certainly for f=1?

@cyckun
Copy link
Author

cyckun commented Apr 16, 2021

Oh, I got it, Thanks for your reply, @lschoe.

@cyckun cyckun closed this as completed Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants