from fastai.basics import *Set up PyTorch links to appear in fastai docs
Test links
test_eq(_mod2page(Tensor), 'tensors.html')
test_eq(_mod2page(torch.nn), 'nn.html')
test_eq(_mod2page(inspect.getmodule(nn.Conv2d)), 'nn.html')
test_eq(_mod2page(F), 'nn.functional.html')
test_eq(_mod2page(torch.optim), 'optim.html')
test_eq(_mod2page(torch.utils.data), 'data.html')pytorch_doc_link
pytorch_doc_link (name:str)
Get the URL to the documentation of a PyTorch module, class or function
| Type | Details | |
|---|---|---|
| name | str | Name of a PyTorch module, class or function |
| Returns | (<class ‘str’>, None) |
test_links = {
'Tensor': 'https://pytorch.org/docs/stable/tensors.html',
'Tensor.sqrt': 'https://pytorch.org/docs/stable/tensors.html#torch.Tensor.sqrt',
'torch.zeros_like': 'https://pytorch.org/docs/stable/torch.html#torch.zeros_like',
'nn.Module': 'https://pytorch.org/docs/stable/nn.html#torch.nn.Module',
'nn.Linear': 'https://pytorch.org/docs/stable/nn.html#torch.nn.Linear',
'F.cross_entropy': 'https://pytorch.org/docs/stable/nn.functional.html#torch.nn.functional.cross_entropy'
}
for f,l in test_links.items(): test_eq(pytorch_doc_link(f), l)