Comments (4)
For reference, this is the code we have in the tests regarding this model 🙂
@pytest.mark.parametrize("batch_size", [1])
@pytest.mark.parametrize("image_dims", [[224, 224]])
def test_resnet_18_imagenet(
batch_size,
image_dims,
dev,
):
ivy.set_backend("torch")
with DefaultDevice(dev):
try:
model = torch.hub.load(
"pytorch/vision:v0.10.0", "resnet18", pretrained=True
)
except urllib.error.URLError:
pytest.skip()
net = ivy.to_ivy_module(model.to(ivy.as_native_dev(dev)))
x0 = ivy.random_uniform(
low=0.0,
high=1.0,
shape=[batch_size] + [3] + image_dims,
dtype=torch.float32,
device=dev,
)
x1 = ivy.random_uniform(
low=0.0,
high=1.0,
shape=[batch_size] + [3] + image_dims,
dtype=torch.float32,
device=dev,
)
ret0_nc = net(x0)
ret1_nc = net(x1)
assert not np.allclose(ivy.to_numpy(ret0_nc), ivy.to_numpy(ret1_nc))
comp_network = compile_graph(net, x0)
show_graph(
net,
x0,
# fname="resnet_18_imagenet.html", # uncomment this to save the graph locally
)
ret0_c = comp_network(x0)
ret1_c = comp_network(x1)
assert not np.allclose(ivy.to_numpy(ret0_c), ivy.to_numpy(ret1_c))
assert np.allclose(ivy.to_numpy(ret0_nc), ivy.to_numpy(ret0_c))
assert np.allclose(ivy.to_numpy(ret1_nc), ivy.to_numpy(ret1_c))
from demos.
The idea is to transpile existing models, you don't have to write one in Ivy 🙂
from demos.
@guillesanbri I have some confusion: should resnet18 be implemented using ivy functional OR can I just load resent18 from torch.hub as in the above example?
from demos.
Done. https://github.com/unifyai/demos/blob/main/temp_demos/compilation_of_various_models/resnet_18.ipynb
from demos.
Related Issues (20)
- HF Jax BERT HOT 1
- Add installation of ivy from source to all notebooks HOT 1
- Fix ordering of notebooks HOT 2
- Transpiling a tensorflow model to build on top of it (transpiler) HOT 1
- Finetuning DeepMind's PerceiverIO in PyTorch (transpiler) HOT 1
- Compilation of a basic function HOT 1
- Plant Disease Recognition Demo
- Music Genre Classification Demo
- Fake News Detection Demo
- Predicting Parking Space Availability Demo
- Artwork Style Recognition Demo
- Energy Consumption Forecasting Demo
- Bird Species Identification Demo HOT 1
- Predicting Taxi Demand Demo HOT 1
- Food Ingredient Recognition Demo
- Sarcasm Detection Demo
- HF Tensorflow DeiT HOT 1
- Credit Card Fraud Detection Demo(Intermediate)
- Chest X-Ray Images (Pneumonia) Detection Demo(Intermediate) HOT 1
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 demos.