keypadml 0.3.0__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. {keypadml-0.3.0 → keypadml-0.3.2}/CHANGELOG.md +11 -1
  2. {keypadml-0.3.0 → keypadml-0.3.2}/CITATION.cff +1 -1
  3. {keypadml-0.3.0/src/keypadml.egg-info → keypadml-0.3.2}/PKG-INFO +36 -8
  4. {keypadml-0.3.0 → keypadml-0.3.2}/README.md +35 -7
  5. keypadml-0.3.2/src/keypadml/_version.py +1 -0
  6. {keypadml-0.3.0 → keypadml-0.3.2/src/keypadml.egg-info}/PKG-INFO +36 -8
  7. keypadml-0.3.0/src/keypadml/_version.py +0 -1
  8. {keypadml-0.3.0 → keypadml-0.3.2}/LICENSE +0 -0
  9. {keypadml-0.3.0 → keypadml-0.3.2}/MANIFEST.in +0 -0
  10. {keypadml-0.3.0 → keypadml-0.3.2}/docs/benchmark-plan.md +0 -0
  11. {keypadml-0.3.0 → keypadml-0.3.2}/docs/benchmark-results.md +0 -0
  12. {keypadml-0.3.0 → keypadml-0.3.2}/docs/guide.md +0 -0
  13. {keypadml-0.3.0 → keypadml-0.3.2}/docs/logo.png +0 -0
  14. {keypadml-0.3.0 → keypadml-0.3.2}/docs/results-format.md +0 -0
  15. {keypadml-0.3.0 → keypadml-0.3.2}/docs/screenshots/nokia6210_pets.png +0 -0
  16. {keypadml-0.3.0 → keypadml-0.3.2}/docs/screenshots/nokia6600i_cifar10.png +0 -0
  17. {keypadml-0.3.0 → keypadml-0.3.2}/docs/screenshots/nokiac7_mnist.png +0 -0
  18. {keypadml-0.3.0 → keypadml-0.3.2}/docs/screenshots/nokiae72_fmnist.png +0 -0
  19. {keypadml-0.3.0 → keypadml-0.3.2}/docs/screenshots/results-page-cifar10.png +0 -0
  20. {keypadml-0.3.0 → keypadml-0.3.2}/docs/screenshots/results-page.png +0 -0
  21. {keypadml-0.3.0 → keypadml-0.3.2}/docs/screenshots/sonyericssonc902_pets.png +0 -0
  22. {keypadml-0.3.0 → keypadml-0.3.2}/docs/try-it.md +0 -0
  23. {keypadml-0.3.0 → keypadml-0.3.2}/examples/big_input.py +0 -0
  24. {keypadml-0.3.0 → keypadml-0.3.2}/examples/cifar10_cnn.py +0 -0
  25. {keypadml-0.3.0 → keypadml-0.3.2}/examples/mnist_lenet.py +0 -0
  26. {keypadml-0.3.0 → keypadml-0.3.2}/java/desktop/kp/desktop/DesktopRun.java +0 -0
  27. {keypadml-0.3.0 → keypadml-0.3.2}/java/desktop/kp/desktop/PhotoRun.java +0 -0
  28. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/Bench.java +0 -0
  29. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/BenchMIDlet.java +0 -0
  30. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/Camera.java +0 -0
  31. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/Card.java +0 -0
  32. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/Inputs.java +0 -0
  33. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/Jpeg.java +0 -0
  34. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/MathX.java +0 -0
  35. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/Net.java +0 -0
  36. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/Ops.java +0 -0
  37. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/Parts.java +0 -0
  38. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/Photo.java +0 -0
  39. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/ResultsCanvas.java +0 -0
  40. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/Saver.java +0 -0
  41. {keypadml-0.3.0 → keypadml-0.3.2}/java/phone/kp/TryIt.java +0 -0
  42. {keypadml-0.3.0 → keypadml-0.3.2}/pyproject.toml +0 -0
  43. {keypadml-0.3.0 → keypadml-0.3.2}/scripts/build_runtime.py +0 -0
  44. {keypadml-0.3.0 → keypadml-0.3.2}/scripts/make_icon.py +0 -0
  45. {keypadml-0.3.0 → keypadml-0.3.2}/setup.cfg +0 -0
  46. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/__init__.py +0 -0
  47. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/desktop/kp/desktop/DesktopRun$1.class +0 -0
  48. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/desktop/kp/desktop/DesktopRun.class +0 -0
  49. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/desktop/kp/desktop/PhotoRun$1.class +0 -0
  50. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/desktop/kp/desktop/PhotoRun.class +0 -0
  51. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/icon.png +0 -0
  52. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Bench$Listener.class +0 -0
  53. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Bench.class +0 -0
  54. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/BenchMIDlet$1.class +0 -0
  55. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/BenchMIDlet$2.class +0 -0
  56. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/BenchMIDlet$3.class +0 -0
  57. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/BenchMIDlet.class +0 -0
  58. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Camera.class +0 -0
  59. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Card$1.class +0 -0
  60. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Card.class +0 -0
  61. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Inputs.class +0 -0
  62. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Jpeg$Huffman.class +0 -0
  63. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Jpeg.class +0 -0
  64. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/MathX.class +0 -0
  65. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Net.class +0 -0
  66. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Ops.class +0 -0
  67. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Parts.class +0 -0
  68. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Photo$Rows.class +0 -0
  69. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Photo.class +0 -0
  70. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/ResultsCanvas.class +0 -0
  71. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/Saver.class +0 -0
  72. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt$1.class +0 -0
  73. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt$2.class +0 -0
  74. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt$3.class +0 -0
  75. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt$4.class +0 -0
  76. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt$5.class +0 -0
  77. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt$6.class +0 -0
  78. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt$7.class +0 -0
  79. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt$8.class +0 -0
  80. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt$Files.class +0 -0
  81. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt$Job.class +0 -0
  82. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt$Snapper.class +0 -0
  83. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_runtime/phone/kp/TryIt.class +0 -0
  84. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/_tools.py +0 -0
  85. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/cli.py +0 -0
  86. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/convert.py +0 -0
  87. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/export.py +0 -0
  88. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/graph.py +0 -0
  89. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/jarfile.py +0 -0
  90. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/photo.py +0 -0
  91. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/py.typed +0 -0
  92. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/reference.py +0 -0
  93. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/report.py +0 -0
  94. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/runner.py +0 -0
  95. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml/serialize.py +0 -0
  96. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml.egg-info/SOURCES.txt +0 -0
  97. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml.egg-info/dependency_links.txt +0 -0
  98. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml.egg-info/entry_points.txt +0 -0
  99. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml.egg-info/requires.txt +0 -0
  100. {keypadml-0.3.0 → keypadml-0.3.2}/src/keypadml.egg-info/top_level.txt +0 -0
  101. {keypadml-0.3.0 → keypadml-0.3.2}/tests/__init__.py +0 -0
  102. {keypadml-0.3.0 → keypadml-0.3.2}/tests/conftest.py +0 -0
  103. {keypadml-0.3.0 → keypadml-0.3.2}/tests/data/nokia6600i_big256_parts.json +0 -0
  104. {keypadml-0.3.0 → keypadml-0.3.2}/tests/data/nokia6600i_big256_v0.3.json +0 -0
  105. {keypadml-0.3.0 → keypadml-0.3.2}/tests/data/nokia6600i_big288_parts.json +0 -0
  106. {keypadml-0.3.0 → keypadml-0.3.2}/tests/data/nokia6600i_cifar10_v0.3.json +0 -0
  107. {keypadml-0.3.0 → keypadml-0.3.2}/tests/data/nokia6600i_lenet_v0.1.txt +0 -0
  108. {keypadml-0.3.0 → keypadml-0.3.2}/tests/data/nokia6600i_lenet_v0.2.txt +0 -0
  109. {keypadml-0.3.0 → keypadml-0.3.2}/tests/data/nokia6600i_lenet_v0.3.json +0 -0
  110. {keypadml-0.3.0 → keypadml-0.3.2}/tests/test_models.py +0 -0
  111. {keypadml-0.3.0 → keypadml-0.3.2}/tests/test_photo.py +0 -0
  112. {keypadml-0.3.0 → keypadml-0.3.2}/tests/test_unit.py +0 -0
@@ -1,6 +1,16 @@
1
1
  # Changelog
2
2
 
3
- ## 0.3.0 (unreleased)
3
+ ## 0.3.2 (2026-12-03)
4
+
5
+ * README: the quick-start example now makes a jar with Try it (camera and photos), trained on
6
+ dark-on-white digits so that a photo of a digit written on paper is read. No change to the library.
7
+
8
+ ## 0.3.1 (2026-12-03)
9
+
10
+ * README: a complete quick-start example (MNIST, a small CNN, one epoch of training, export and
11
+ check on the PC), shorter overview, and links that work on PyPI. No change to the library.
12
+
13
+ ## 0.3.0 (2026-12-03)
4
14
 
5
15
  * **Benchmark results on real phones.** The 20 benchmark jars ran on a Nokia 6600i slide, 6210 Navigator,
6
16
  E72 and C7; the results files are in `results/<phone model>/` and summarised in the README and
@@ -5,4 +5,4 @@ type: software
5
5
  authors:
6
6
  - name: "Said Ohamouddou"
7
7
  license: Apache-2.0
8
- version: 0.3.0
8
+ version: 0.3.2
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: keypadml
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Run and benchmark PyTorch CNNs on old Java ME feature phones: export to a .jar, run it on the phone, check it against PyTorch.
5
5
  Author: Said Ohamouddou
6
6
  License-Expression: Apache-2.0
@@ -70,21 +70,49 @@ Optional: Java 8 or newer, to test a jar on your PC (`keypadml verify`) or in an
70
70
 
71
71
  ## Quick start
72
72
 
73
- **1. Export** your model with a few test inputs:
73
+ A complete example: dataset, CNN, training and export (needs `pip install keypadml torchvision`).
74
74
 
75
75
  ```python
76
+ import torch
77
+ import torch.nn as nn
78
+ import torch.nn.functional as F
79
+ from torchvision import datasets, transforms
76
80
  import keypadml
77
81
 
78
- inputs, labels = keypadml.sample(test_dataset, n=50)
79
- result = keypadml.export(model, inputs, labels, out_dir="bench", name="LeNet")
82
+ # 1. Dataset: MNIST digits, inverted to dark ink on white, like a photo of a digit on paper
83
+ tf = transforms.Compose([transforms.ToTensor(), lambda t: 1 - t])
84
+ train = datasets.MNIST("data", train=True, download=True, transform=tf)
85
+ test = datasets.MNIST("data", train=False, download=True, transform=tf)
86
+
87
+ # 2. A small CNN: two conv blocks and a classifier
88
+ model = nn.Sequential(
89
+ nn.Conv2d(1, 8, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2), # 8 x 14 x 14
90
+ nn.Conv2d(8, 16, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2), # 16 x 7 x 7
91
+ nn.Flatten(), nn.Linear(16 * 7 * 7, 10),
92
+ )
93
+
94
+ # 3. Train for one epoch (a few seconds on a CPU)
95
+ opt = torch.optim.Adam(model.parameters(), lr=1e-3)
96
+ for x, y in torch.utils.data.DataLoader(train, batch_size=64, shuffle=True):
97
+ opt.zero_grad()
98
+ F.cross_entropy(model(x), y).backward()
99
+ opt.step()
100
+
101
+ # 4. Export the model with 20 test digits to bench/MNIST.jar
102
+ inputs, labels = keypadml.sample(test, n=20)
103
+ result = keypadml.export(model.eval(), inputs, labels, out_dir="bench", name="MNIST",
104
+ class_names=[str(d) for d in range(10)],
105
+ photo=dict(mean=[0.0], std=[1.0])) # Try it: camera and photos
80
106
  print(result) # jar size, parameters, multiply-adds, memory estimate
81
- keypadml.verify(result) # optional: run the phone's code on this PC
107
+ keypadml.verify(result) # optional (needs Java): run the phone's code on this PC
82
108
  ```
83
109
 
84
- **2. Run on the phone.** Copy `bench/LeNet.jar` to the phone, open it and press **Start**.
85
- The results are saved on the memory card in `keypadml/<phone model>/`.
110
+ **Run it on the phone.** Copy `bench/MNIST.jar` to the phone, open it and press **Start**. The
111
+ results are saved on the memory card in `keypadml/<phone model>/`. Then choose **Try it: camera** and
112
+ photograph a digit written large with a dark pen on white paper, filling the middle of the picture:
113
+ the phone shows the digit it reads.
86
114
 
87
- **3. Read the report** on your computer (a real Nokia 6600i run, shortened):
115
+ **Read the report** on your computer. Here is a real Nokia 6600i run of a LeNet (shortened):
88
116
 
89
117
  ```text
90
118
  $ keypadml report kp_LeNet_123456.json --ref bench
@@ -42,21 +42,49 @@ Optional: Java 8 or newer, to test a jar on your PC (`keypadml verify`) or in an
42
42
 
43
43
  ## Quick start
44
44
 
45
- **1. Export** your model with a few test inputs:
45
+ A complete example: dataset, CNN, training and export (needs `pip install keypadml torchvision`).
46
46
 
47
47
  ```python
48
+ import torch
49
+ import torch.nn as nn
50
+ import torch.nn.functional as F
51
+ from torchvision import datasets, transforms
48
52
  import keypadml
49
53
 
50
- inputs, labels = keypadml.sample(test_dataset, n=50)
51
- result = keypadml.export(model, inputs, labels, out_dir="bench", name="LeNet")
54
+ # 1. Dataset: MNIST digits, inverted to dark ink on white, like a photo of a digit on paper
55
+ tf = transforms.Compose([transforms.ToTensor(), lambda t: 1 - t])
56
+ train = datasets.MNIST("data", train=True, download=True, transform=tf)
57
+ test = datasets.MNIST("data", train=False, download=True, transform=tf)
58
+
59
+ # 2. A small CNN: two conv blocks and a classifier
60
+ model = nn.Sequential(
61
+ nn.Conv2d(1, 8, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2), # 8 x 14 x 14
62
+ nn.Conv2d(8, 16, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2), # 16 x 7 x 7
63
+ nn.Flatten(), nn.Linear(16 * 7 * 7, 10),
64
+ )
65
+
66
+ # 3. Train for one epoch (a few seconds on a CPU)
67
+ opt = torch.optim.Adam(model.parameters(), lr=1e-3)
68
+ for x, y in torch.utils.data.DataLoader(train, batch_size=64, shuffle=True):
69
+ opt.zero_grad()
70
+ F.cross_entropy(model(x), y).backward()
71
+ opt.step()
72
+
73
+ # 4. Export the model with 20 test digits to bench/MNIST.jar
74
+ inputs, labels = keypadml.sample(test, n=20)
75
+ result = keypadml.export(model.eval(), inputs, labels, out_dir="bench", name="MNIST",
76
+ class_names=[str(d) for d in range(10)],
77
+ photo=dict(mean=[0.0], std=[1.0])) # Try it: camera and photos
52
78
  print(result) # jar size, parameters, multiply-adds, memory estimate
53
- keypadml.verify(result) # optional: run the phone's code on this PC
79
+ keypadml.verify(result) # optional (needs Java): run the phone's code on this PC
54
80
  ```
55
81
 
56
- **2. Run on the phone.** Copy `bench/LeNet.jar` to the phone, open it and press **Start**.
57
- The results are saved on the memory card in `keypadml/<phone model>/`.
82
+ **Run it on the phone.** Copy `bench/MNIST.jar` to the phone, open it and press **Start**. The
83
+ results are saved on the memory card in `keypadml/<phone model>/`. Then choose **Try it: camera** and
84
+ photograph a digit written large with a dark pen on white paper, filling the middle of the picture:
85
+ the phone shows the digit it reads.
58
86
 
59
- **3. Read the report** on your computer (a real Nokia 6600i run, shortened):
87
+ **Read the report** on your computer. Here is a real Nokia 6600i run of a LeNet (shortened):
60
88
 
61
89
  ```text
62
90
  $ keypadml report kp_LeNet_123456.json --ref bench
@@ -0,0 +1 @@
1
+ __version__ = "0.3.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: keypadml
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Run and benchmark PyTorch CNNs on old Java ME feature phones: export to a .jar, run it on the phone, check it against PyTorch.
5
5
  Author: Said Ohamouddou
6
6
  License-Expression: Apache-2.0
@@ -70,21 +70,49 @@ Optional: Java 8 or newer, to test a jar on your PC (`keypadml verify`) or in an
70
70
 
71
71
  ## Quick start
72
72
 
73
- **1. Export** your model with a few test inputs:
73
+ A complete example: dataset, CNN, training and export (needs `pip install keypadml torchvision`).
74
74
 
75
75
  ```python
76
+ import torch
77
+ import torch.nn as nn
78
+ import torch.nn.functional as F
79
+ from torchvision import datasets, transforms
76
80
  import keypadml
77
81
 
78
- inputs, labels = keypadml.sample(test_dataset, n=50)
79
- result = keypadml.export(model, inputs, labels, out_dir="bench", name="LeNet")
82
+ # 1. Dataset: MNIST digits, inverted to dark ink on white, like a photo of a digit on paper
83
+ tf = transforms.Compose([transforms.ToTensor(), lambda t: 1 - t])
84
+ train = datasets.MNIST("data", train=True, download=True, transform=tf)
85
+ test = datasets.MNIST("data", train=False, download=True, transform=tf)
86
+
87
+ # 2. A small CNN: two conv blocks and a classifier
88
+ model = nn.Sequential(
89
+ nn.Conv2d(1, 8, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2), # 8 x 14 x 14
90
+ nn.Conv2d(8, 16, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2), # 16 x 7 x 7
91
+ nn.Flatten(), nn.Linear(16 * 7 * 7, 10),
92
+ )
93
+
94
+ # 3. Train for one epoch (a few seconds on a CPU)
95
+ opt = torch.optim.Adam(model.parameters(), lr=1e-3)
96
+ for x, y in torch.utils.data.DataLoader(train, batch_size=64, shuffle=True):
97
+ opt.zero_grad()
98
+ F.cross_entropy(model(x), y).backward()
99
+ opt.step()
100
+
101
+ # 4. Export the model with 20 test digits to bench/MNIST.jar
102
+ inputs, labels = keypadml.sample(test, n=20)
103
+ result = keypadml.export(model.eval(), inputs, labels, out_dir="bench", name="MNIST",
104
+ class_names=[str(d) for d in range(10)],
105
+ photo=dict(mean=[0.0], std=[1.0])) # Try it: camera and photos
80
106
  print(result) # jar size, parameters, multiply-adds, memory estimate
81
- keypadml.verify(result) # optional: run the phone's code on this PC
107
+ keypadml.verify(result) # optional (needs Java): run the phone's code on this PC
82
108
  ```
83
109
 
84
- **2. Run on the phone.** Copy `bench/LeNet.jar` to the phone, open it and press **Start**.
85
- The results are saved on the memory card in `keypadml/<phone model>/`.
110
+ **Run it on the phone.** Copy `bench/MNIST.jar` to the phone, open it and press **Start**. The
111
+ results are saved on the memory card in `keypadml/<phone model>/`. Then choose **Try it: camera** and
112
+ photograph a digit written large with a dark pen on white paper, filling the middle of the picture:
113
+ the phone shows the digit it reads.
86
114
 
87
- **3. Read the report** on your computer (a real Nokia 6600i run, shortened):
115
+ **Read the report** on your computer. Here is a real Nokia 6600i run of a LeNet (shortened):
88
116
 
89
117
  ```text
90
118
  $ keypadml report kp_LeNet_123456.json --ref bench
@@ -1 +0,0 @@
1
- __version__ = "0.3.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes