Comments (4)
You can use the torch.onnx
package.
When you have your trained OFA network as ofa_network
you can sample a random subnet with ofa_network.sample_active_subnet()
than you can cut that network with subnet = ofa_network.get_active_subnet()
. Don't forget to reset the batch norm statistics reset_running_statistics(net=subnet)
. Then you can export it like any model.
torch.onnx.export(
subnet,
torch.randn(1, 3, 224, 224),
'model_name.onnx',
export_params=True,
)
from once-for-all.
Yes, I do have the same Question.
from once-for-all.
You can use the
torch.onnx
package.When you have your trained OFA network as
ofa_network
you can sample a random subnet withofa_network.sample_active_subnet()
than you can cut that network withsubnet = ofa_network.get_active_subnet()
. Don't forget to reset the batch norm statisticsreset_running_statistics(net=subnet)
. Then you can export it like any model.torch.onnx.export( subnet, torch.randn(1, 3, 224, 224), 'model_name.onnx', export_params=True, )
How to extract the subnet according to these preset configs like "pixel2_lat@[email protected]_finetune@25"? After I load the big OFA pretrained on a custom dataset, I can not figure out how to get the subnet according to the preset config.
from once-for-all.
You can use the
torch.onnx
package.
When you have your trained OFA network asofa_network
you can sample a random subnet withofa_network.sample_active_subnet()
than you can cut that network withsubnet = ofa_network.get_active_subnet()
. Don't forget to reset the batch norm statisticsreset_running_statistics(net=subnet)
. Then you can export it like any model.torch.onnx.export( subnet, torch.randn(1, 3, 224, 224), 'model_name.onnx', export_params=True, )
How to extract the subnet according to these preset configs like "pixel2_lat@[email protected]_finetune@25"? After I load the big OFA pretrained on a custom dataset, I can not figure out how to get the subnet according to the preset config.
I' have not tried this myself, but I would try something like this
Either:
Write a script that generates an architecture configuration as needed by this function
from the net.config
file. Then do everything as described previously.
Or:
Create a model with the desired architecture, as it is done here. In your example for net_id
use "pixel2_lat@[email protected]_finetune@25".
Now a little work is needed. You need to load the weights from your OFA network into the subnetwork. Therefore, you need to write a function similar to this. But only load the values from your OFA network that are needed in the subnet architecture.
You also have to reset_running_statistics()
for the subnet.
Then you can export the subnetwork as described previously.
from once-for-all.
Related Issues (20)
- KeyError from MBv3LatencyTable in EvolutionFinder
- ImportError: cannot import name 'MyRandomResizedCrop' HOT 1
- How to train my own acc predictor and efficiency predictor HOT 2
- All memory on one card
- How to cal calculate the mobile_trim.yaml?
- KeyError: <InterpolationMode.BILINEAR: 'bilinear'> HOT 4
- expand_ratio BUG?
- Using Once-for-all for a custom CNN HOT 1
- torch.hub example is broken HOT 2
- error when custom sub sampling a model HOT 1
- Each network in the child pool has the same architecture?
- About the pre-trained hypernetwork used for the results in Table 1, is it ofa_mbv3_d234_e346_k357_w1.0 or ofa_mbv3_d234_e346_k357_w1.2?
- Missing dependency numpy
- imagenet_1k.zip HOT 1
- [Easy fix] OFA Tutorial On colab
- Can't download `ofa_resnet50` super network HOT 3
- How do i specialize OFA for cifar10
- Resnet50 Access Denied
- LatencyTable Target Hardware Error
- Additional requirements for running the notebool
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from once-for-all.