-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Extended unit tests to classifier and fixed pooling (#17) * Extended unit tests to classifier and fixed pooling * Changed trigger of doctest workflow * Fixing issue #18 * fixed linters * Add pre-commit hooks * Doctest only on PRs * Fixed network conversion from GPU Also tested on Windows machine. * Create python_versions.yml * Update and rename python_versions.yml to tests.yml * Update export.yaml * CI fix (#21) * Create pre-commit.yaml * remove code.yaml * fixing pre-commit * Doctest with pytest * change trigger * change trigger * Delete LICENSE * checkpoint from filesystem (#20) * checkpoint from filesystem * fixed deps * Update README.md * Update LICENSE * Updating LICENSE --------- Co-authored-by: fpaissan <[email protected]> Co-authored-by: Francesco Paissan <[email protected]> * Create LICENSE (#22) * Update README.md (#23) * new min python version to 3.8 * 🐛 extra_requirements now have a version - fixed CI (#24) * 🐛 extra_requirements now have a version * fixed linter errors * testing actions * fixed linter * removing tf_probability * fixed tf prob version --------- Co-authored-by: fpaissan <[email protected]> * Documentation upgrade - guide for contribution (#25) * add contribution guide to docs * documentation with contribution guide * cosmetic * bump version 0.0.4 -> 0.0.5 * Bump requests from 2.28.2 to 2.31.0 (#27) Bumps [requests](https://github.com/psf/requests) from 2.28.2 to 2.31.0. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](psf/requests@v2.28.2...v2.31.0) --- updated-dependencies: - dependency-name: requests dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix pypi release * Update README.md (#29) * Patch for faster GPU inference (#35) * Patch for faster GPU inference * remove unused zeropad def --------- Co-authored-by: fpaissan <[email protected]> * initial commit * add eval loop * add acceleration * modules as dict * add checkpointer * minor * load best checkpoint * restore epoch, optimizer, lr sched * fix logging on multi-gpu * minor fixes * working on single gpu * fix checkpointer + multi-gpu * fp16 might not be ok yet * load_modules and unwrap_model * fixed convert and export * cosmetic on export * add argparse * add metrics -- check something is off with acc * its print strange * fixed checkpointer viz * fix checkpointers and metrics * cosmetic * linters * add credits * fix requirements * fix unittest * remove recipes * remove unused files * remove unused fuctions from networks * fix tests * hot fix * onnx conversion without convert * fix requirements * add default class config and temp folder for debug mode * add doc for class Metric * finish doc MicroMind * update docs * linters fix * new initial page * bump version 0.0.5 -> 0.1.0 * final touches and bumpver --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Matteo Beltrami <[email protected]> Co-authored-by: SebastianCavada <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matteo Tremonti <[email protected]> Co-authored-by: Matteo Beltrami <[email protected]>
- Loading branch information
1 parent
b4747c1
commit d318e0b
Showing
23 changed files
with
1,097 additions
and
2,038 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
micromind package | ||
================= | ||
|
||
micromind.core module | ||
--------------------- | ||
|
||
.. automodule:: micromind.core | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
micromind.convert module | ||
------------------------ | ||
|
||
.. automodule:: micromind.convert | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Subpackages | ||
----------- | ||
|
||
.. toctree:: | ||
:maxdepth: 4 | ||
:maxdepth: 2 | ||
|
||
micromind.conversion | ||
micromind.networks | ||
micromind.utils | ||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: micromind | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from micromind import MicroMind, Metric | ||
from micromind.networks import PhiNet | ||
from micromind.utils.parse import parse_arguments | ||
|
||
import torch | ||
import torch.nn as nn | ||
import torchvision | ||
import torchvision.transforms as transforms | ||
|
||
batch_size = 128 | ||
|
||
|
||
class ImageClassification(MicroMind): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
self.modules["classifier"] = PhiNet( | ||
(3, 32, 32), include_top=True, num_classes=10 | ||
) | ||
|
||
def forward(self, batch): | ||
return self.modules["classifier"](batch[0]) | ||
|
||
def compute_loss(self, pred, batch): | ||
return nn.CrossEntropyLoss()(pred, batch[1]) | ||
|
||
|
||
if __name__ == "__main__": | ||
hparams = parse_arguments() | ||
m = ImageClassification(hparams) | ||
|
||
def compute_accuracy(pred, batch): | ||
tmp = (pred.argmax(1) == batch[1]).float() | ||
return tmp | ||
|
||
transform = transforms.Compose( | ||
[transforms.ToTensor(), transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] | ||
) | ||
|
||
trainset = torchvision.datasets.CIFAR10( | ||
root="data/cifar-10", train=True, download=True, transform=transform | ||
) | ||
trainloader = torch.utils.data.DataLoader( | ||
trainset, batch_size=batch_size, shuffle=True, num_workers=1 | ||
) | ||
|
||
testset = torchvision.datasets.CIFAR10( | ||
root="data/cifar-10", train=False, download=True, transform=transform | ||
) | ||
testloader = torch.utils.data.DataLoader( | ||
testset, batch_size=batch_size, shuffle=False, num_workers=1 | ||
) | ||
|
||
acc = Metric(name="accuracy", fn=compute_accuracy) | ||
|
||
m.train( | ||
epochs=10, | ||
datasets={"train": trainloader, "val": testloader, "test": testloader}, | ||
metrics=[acc], | ||
debug=hparams.debug, | ||
) | ||
|
||
m.test( | ||
datasets={"test": testloader}, | ||
) | ||
|
||
m.export("output_onnx", "onnx", (3, 32, 32)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.