repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
fastai
fastai-master/fastai/losses.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01a_losses.ipynb. # %% ../nbs/01a_losses.ipynb 2 from __future__ import annotations from .imports import * from .torch_imports import * from .torch_core import * from .layers import * # %% auto 0 __all__ = ['BaseLoss', 'CrossEntropyLossFlat', 'FocalLoss', 'FocalLossF...
11,450
40.043011
130
py
fastai
fastai-master/fastai/torch_core.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_torch_core.ipynb. # %% ../nbs/00_torch_core.ipynb 2 from __future__ import annotations from .imports import * from .torch_imports import * from packaging.version import parse # %% auto 0 __all__ = ['norm_types', 'setup_cuda', 'subplots', 'show_image', 'show_titled...
36,527
39.40708
168
py
fastai
fastai-master/fastai/torch_basics.py
from torch import multiprocessing import platform,os if platform.system()=='Darwin': # Python 3.8 changed to 'spawn' but that doesn't work with PyTorch DataLoader w n_workers>0 multiprocessing.set_start_method('fork', force=True) # workaround "OMP: Error #15: Initializing libiomp5.dylib, but found libomp.dy...
516
35.928571
106
py
fastai
fastai-master/fastai/torch_imports.py
import pandas as pd import torch from torch import as_tensor,Tensor,ByteTensor,LongTensor,FloatTensor,HalfTensor,DoubleTensor import torch.nn as nn import torch.nn.functional as F from torch.utils.data import SequentialSampler,RandomSampler,Sampler,BatchSampler from torch.utils.data import IterableDataset,get_worker_in...
400
39.1
92
py
fastai
fastai-master/fastai/learner.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/13a_learner.ipynb. # %% ../nbs/13a_learner.ipynb 2 from __future__ import annotations from .data.all import * from .optimizer import * from .callback.core import * import pickle,threading from collections.abc import MutableSequence # %% auto 0 __all__ = ['replacing_y...
29,917
43.388724
155
py
fastai
fastai-master/fastai/_modidx.py
# Autogenerated by nbdev d = { 'settings': { 'branch': 'master', 'doc_baseurl': '/', 'doc_host': 'https://docs.fast.ai', 'git_url': 'https://github.com/fastai/fastai', 'lib_path': 'fastai'}, 'syms': { 'fastai.basics': {}, 'fastai.callback.al...
338,820
124.118538
196
py
fastai
fastai-master/fastai/collab.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/45_collab.ipynb. # %% ../nbs/45_collab.ipynb 2 from __future__ import annotations from .tabular.all import * # %% auto 0 __all__ = ['TabularCollab', 'CollabDataLoaders', 'EmbeddingDotBias', 'EmbeddingNN', 'collab_learner'] # %% ../nbs/45_collab.ipynb 7 class Tabular...
5,199
49.485437
221
py
fastai
fastai-master/fastai/interpret.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/20_interpret.ipynb. # %% ../nbs/20_interpret.ipynb 2 from __future__ import annotations from .data.all import * from .optimizer import * from .learner import * from .tabular.core import * import sklearn.metrics as skm # %% auto 0 __all__ = ['plot_top_losses', 'Interp...
7,769
43.913295
112
py
fastai
fastai-master/fastai/layers.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_layers.ipynb. # %% ../nbs/01_layers.ipynb 2 from __future__ import annotations from .imports import * from .torch_imports import * from .torch_core import * from torch.nn.utils import weight_norm, spectral_norm # %% auto 0 __all__ = ['NormType', 'inplace_relu', 'm...
27,282
40.526636
127
py
fastai
fastai-master/fastai/_pytorch_doc.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/99_pytorch_doc.ipynb. # %% ../nbs/99_pytorch_doc.ipynb 5 from __future__ import annotations from types import ModuleType # %% auto 0 __all__ = ['PYTORCH_URL', 'pytorch_doc_link'] # %% ../nbs/99_pytorch_doc.ipynb 6 PYTORCH_URL = 'https://pytorch.org/docs/stable/' # ...
1,573
32.489362
77
py
fastai
fastai-master/fastai/distributed.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/20a_distributed.ipynb. # %% ../nbs/20a_distributed.ipynb 2 from __future__ import annotations from .basics import * from .callback.progress import ProgressCallback from torch.nn.parallel import DistributedDataParallel, DataParallel from .data.load import _FakeLoader,_...
9,784
42.878924
144
py
fastai
fastai-master/fastai/metrics.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/13b_metrics.ipynb. # %% ../nbs/13b_metrics.ipynb 1 from __future__ import annotations from .data.all import * from .optimizer import * from .learner import * # %% auto 0 __all__ = ['rmse', 'exp_rmspe', 'perplexity', 'AccumMetric', 'skm_to_fastai', 'optim_metric', 'ac...
22,629
48.195652
130
py
fastai
fastai-master/fastai/_nbdev.py
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"defaults.benchmark": "00_torch_core.ipynb", "setup_cuda": "00_torch_core.ipynb", "subplots": "00_torch_core.ipynb", "show_image": "00_torch_core.ipynb", "show_titled_image...
44,456
48.396667
74
py
fastai
fastai-master/fastai/fp16_utils.py
#Code directly taken from NVIDIA apex: https://github.com/NVIDIA/apex import torch import torch.nn as nn from torch.autograd import Variable from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors class tofp16(nn.Module): """ Utility module that implements:: def forward(self, input)...
6,957
37.230769
337
py
fastai
fastai-master/fastai/optimizer.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/12_optimizer.ipynb. # %% ../nbs/12_optimizer.ipynb 2 from __future__ import annotations from .torch_basics import * # %% auto 0 __all__ = ['pytorch_hp_map', 'Optimizer', 'sgd_step', 'weight_decay', 'l2_reg', 'average_grad', 'average_sqr_grad', 'momentum_st...
21,187
41.717742
139
py
fastai
fastai-master/fastai/test_utils.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/97_test_utils.ipynb. # %% ../nbs/97_test_utils.ipynb 0 from __future__ import annotations from .imports import * from .data.all import * from .optimizer import * from .learner import * from .callback.core import * from torch.utils.data import TensorDataset # %% auto ...
6,033
35.131737
151
py
fastai
fastai-master/fastai/callback/hook.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/15_callback.hook.ipynb. # %% ../../nbs/15_callback.hook.ipynb 1 from __future__ import annotations from ..basics import * # %% auto 0 __all__ = ['Hook', 'hook_output', 'Hooks', 'hook_outputs', 'dummy_eval', 'model_sizes', 'num_features_model', 'has_params', ...
11,381
39.361702
142
py
fastai
fastai-master/fastai/callback/tracker.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/17_callback.tracker.ipynb. # %% ../../nbs/17_callback.tracker.ipynb 2 from __future__ import annotations from ..basics import * from .progress import * from .fp16 import MixedPrecision # %% auto 0 __all__ = ['TerminateOnNaNCallback', 'TrackerCallback', 'EarlyStopp...
7,720
54.15
148
py
fastai
fastai-master/fastai/callback/core.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/13_callback.core.ipynb. # %% ../../nbs/13_callback.core.ipynb 2 from __future__ import annotations from ..data.all import * from ..optimizer import * from ..losses import BaseLoss # %% auto 0 __all__ = ['Callback', 'TrainEvalCallback', 'GatherPredsCallback', 'Fetc...
9,371
48.851064
180
py
fastai
fastai-master/fastai/callback/channelslast.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/18c_callback.channelslast.ipynb. # %% ../../nbs/18c_callback.channelslast.ipynb 1 from __future__ import annotations from ..basics import * from .fp16 import MixedPrecision from torch.cuda.amp import GradScaler # %% auto 0 __all__ = ['ChannelsLast'] # %% ../../n...
1,614
37.452381
102
py
fastai
fastai-master/fastai/callback/captum.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/70c_callback.captum.ipynb. # %% ../../nbs/70c_callback.captum.ipynb 3 from __future__ import annotations import tempfile from ..basics import * # %% auto 0 __all__ = ['CaptumInterpretation'] # %% ../../nbs/70c_callback.captum.ipynb 6 from ipykernel import jsonuti...
5,807
49.947368
146
py
fastai
fastai-master/fastai/callback/tensorboard.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/70a_callback.tensorboard.ipynb. # %% ../../nbs/70a_callback.tensorboard.ipynb 3 from __future__ import annotations from ..basics import * # %% auto 0 __all__ = ['TensorBoardBaseCallback', 'TensorBoardCallback', 'TensorBoardProjectorCallback', 'projector_word_embed...
7,323
41.33526
121
py
fastai
fastai-master/fastai/callback/mixup.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/19_callback.mixup.ipynb. # %% ../../nbs/19_callback.mixup.ipynb 2 from __future__ import annotations from ..basics import * from torch.distributions.beta import Beta # %% auto 0 __all__ = ['reduce_loss', 'MixHandler', 'MixUp', 'CutMix'] # %% ../../nbs/19_callback...
4,833
42.160714
114
py
fastai
fastai-master/fastai/callback/schedule.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/14_callback.schedule.ipynb. # %% ../../nbs/14_callback.schedule.ipynb 2 from __future__ import annotations from ..basics import * from .tracker import SaveModelCallback # %% auto 0 __all__ = ['annealer', 'sched_lin', 'sched_cos', 'sched_no', 'sched_exp', 'SchedLin...
14,363
44.6
136
py
fastai
fastai-master/fastai/callback/fp16.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/18_callback.fp16.ipynb. # %% ../../nbs/18_callback.fp16.ipynb 2 from __future__ import annotations from ..basics import * from .progress import * from torch.cuda.amp import GradScaler,autocast from torch.cuda.amp.grad_scaler import OptState # %% auto 0 __all__ = ...
10,319
46.33945
139
py
fastai
fastai-master/fastai/vision/core.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/07_vision.core.ipynb. # %% ../../nbs/07_vision.core.ipynb 2 from __future__ import annotations from ..torch_basics import * from ..data.all import * from PIL import Image try: BILINEAR,NEAREST = Image.Resampling.BILINEAR,Image.Resampling.NEAREST except AttributeE...
11,701
36.993506
124
py
fastai
fastai-master/fastai/vision/widgets.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/09c_vision.widgets.ipynb. # %% ../../nbs/09c_vision.widgets.ipynb 3 from __future__ import annotations from ..torch_basics import * from ..data.all import * from .core import * from fastcore.parallel import * from ipywidgets import HBox,VBox,widgets,Button,Checkbox...
5,186
40.830645
124
py
fastai
fastai-master/fastai/vision/augment.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/09_vision.augment.ipynb. # %% ../../nbs/09_vision.augment.ipynb 3 from __future__ import annotations from ..data.all import * from .core import * from .data import * # %% auto 0 __all__ = ['TensorTypes', 'RandTransform', 'FlipItem', 'DihedralItem', 'CropPad', 'Ran...
57,110
43.898585
134
py
fastai
fastai-master/fastai/vision/utils.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/09b_vision.utils.ipynb. # %% ../../nbs/09b_vision.utils.ipynb 3 from __future__ import annotations import uuid from ..torch_basics import * from ..data.all import * from .core import * from fastdownload import download_url from pathlib import Path # %% auto 0 __al...
4,333
40.673077
128
py
fastai
fastai-master/fastai/vision/gan.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/24_vision.gan.ipynb. # %% ../../nbs/24_vision.gan.ipynb 2 from __future__ import annotations from ..basics import * from .all import * # %% auto 0 __all__ = ['GANModule', 'basic_critic', 'AddChannels', 'basic_generator', 'DenseResBlock', 'gan_critic', 'GANLoss', ...
19,560
45.463183
150
py
fastai
fastai-master/fastai/vision/data.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/08_vision.data.ipynb. # %% ../../nbs/08_vision.data.ipynb 2 from __future__ import annotations from ..torch_basics import * from ..data.all import * from .core import * import types # %% auto 0 __all__ = ['PointBlock', 'BBoxBlock', 'get_grid', 'clip_remove_empty',...
11,758
52.45
137
py
fastai
fastai-master/fastai/vision/models/tvm.py
from torchvision.models import * import types as _t _g = globals() for _k, _v in list(_g.items()): if ( isinstance(_v, _t.ModuleType) and _v.__name__.startswith("torchvision.models") ) or (callable(_v) and _v.__module__ == "torchvision.models._api"): del _g[_k] del _k, _v, _g, _t
307
24.666667
86
py
fastai
fastai-master/fastai/vision/models/xresnet.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../../nbs/11_vision.models.xresnet.ipynb. # %% ../../../nbs/11_vision.models.xresnet.ipynb 2 from __future__ import annotations from ...torch_basics import * try: from torchvision.models.utils import load_state_dict_from_url except ModuleNotFoundError: from torch.hub impo...
7,766
69.609091
156
py
fastai
fastai-master/fastai/vision/models/unet.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../../nbs/15a_vision.models.unet.ipynb. # %% ../../../nbs/15a_vision.models.unet.ipynb 1 from __future__ import annotations from ...torch_basics import * from ...callback.hook import * # %% auto 0 __all__ = ['UnetBlock', 'ResizeToOrig', 'DynamicUnet'] # %% ../../../nbs/...
4,724
47.71134
118
py
fastai
fastai-master/fastai/tabular/core.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/40_tabular.core.ipynb. # %% ../../nbs/40_tabular.core.ipynb 2 from __future__ import annotations from ..torch_basics import * from ..data.all import * # %% auto 0 __all__ = ['make_date', 'add_datepart', 'add_elapsed_times', 'cont_cat_split', 'df_shrink_dtypes', 'd...
16,968
43.075325
133
py
fastai
fastai-master/fastai/tabular/model.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/42_tabular.model.ipynb. # %% ../../nbs/42_tabular.model.ipynb 1 from __future__ import annotations from ..torch_basics import * from .core import * # %% auto 0 __all__ = ['emb_sz_rule', 'get_emb_sz', 'TabularModel', 'tabular_config'] # %% ../../nbs/42_tabular.mod...
3,750
45.8875
128
py
fastai
fastai-master/fastai/tabular/data.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/41_tabular.data.ipynb. # %% ../../nbs/41_tabular.data.ipynb 2 from __future__ import annotations from ..torch_basics import * from ..data.all import * from .core import * # %% auto 0 __all__ = ['TabularDataLoaders'] # %% ../../nbs/41_tabular.data.ipynb 7 class Ta...
2,768
45.932203
104
py
fastai
fastai-master/fastai/medical/imaging.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/60_medical.imaging.ipynb. # %% ../../nbs/60_medical.imaging.ipynb 4 from __future__ import annotations from ..basics import * from ..vision.all import * from ..data.transforms import * import pydicom,kornia,skimage from pydicom.dataset import Dataset as DcmDataset...
15,588
36.92944
136
py
fastai
fastai-master/fastai/data/core.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/03_data.core.ipynb. # %% ../../nbs/03_data.core.ipynb 3 from __future__ import annotations from ..torch_basics import * from .load import * # %% auto 0 __all__ = ['show_batch', 'show_results', 'TfmdDL', 'DataLoaders', 'FilteredBase', 'TfmdLists', 'decode_at', 'sho...
24,537
44.609665
172
py
fastai
fastai-master/fastai/data/all.py
from ..torch_basics import * from .core import * from .load import * from .external import * from .transforms import * from .block import *
140
19.142857
28
py
fastai
fastai-master/fastai/data/block.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/06_data.block.ipynb. # %% ../../nbs/06_data.block.ipynb 2 from __future__ import annotations from ..torch_basics import * from .core import * from .load import * from .external import * from .transforms import * # %% auto 0 __all__ = ['TransformBlock', 'CategoryBl...
11,106
44.150407
147
py
fastai
fastai-master/fastai/data/external.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/04_data.external.ipynb. # %% ../../nbs/04_data.external.ipynb 2 from __future__ import annotations from ..torch_basics import * from fastdownload import FastDownload from functools import lru_cache import fastai.data # %% auto 0 __all__ = ['fastai_cfg', 'fastai_pa...
6,020
42.948905
118
py
fastai
fastai-master/fastai/data/load.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/02_data.load.ipynb. # %% ../../nbs/02_data.load.ipynb 3 from __future__ import annotations from ..torch_basics import * from torch.utils.data.dataloader import _MultiProcessingDataLoaderIter,_SingleProcessDataLoaderIter,_DatasetKind _loaders = (_MultiProcessingData...
10,928
53.919598
282
py
fastai
fastai-master/fastai/data/transforms.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/05_data.transforms.ipynb. # %% ../../nbs/05_data.transforms.ipynb 2 from __future__ import annotations from ..torch_basics import * from .core import * from .load import * from .external import * from sklearn.model_selection import train_test_split import posixpa...
16,883
43.083551
147
py
fastai
fastai-master/fastai/text/core.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/30_text.core.ipynb. # %% ../../nbs/30_text.core.ipynb 1 from __future__ import annotations from ..torch_basics import * from ..data.all import * # %% auto 0 __all__ = ['UNK', 'PAD', 'BOS', 'EOS', 'FLD', 'TK_REP', 'TK_WREP', 'TK_UP', 'TK_MAJ', 'WordTokenizer', 'fn_...
17,521
45.110526
121
py
fastai
fastai-master/fastai/text/learner.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/37_text.learner.ipynb. # %% ../../nbs/37_text.learner.ipynb 1 from __future__ import annotations from ..basics import * from .core import * from .data import * from .models.core import * from .models.awdlstm import * from ..callback.rnn import * from ..callback.pro...
13,867
44.618421
133
py
fastai
fastai-master/fastai/text/data.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/31_text.data.ipynb. # %% ../../nbs/31_text.data.ipynb 1 from __future__ import annotations from ..torch_basics import * from ..data.all import * from .core import * # %% auto 0 __all__ = ['pad_input', 'reverse_text', 'make_vocab', 'TensorText', 'LMTensorText', 'Nu...
14,582
49.811847
141
py
fastai
fastai-master/fastai/text/models/core.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../../nbs/33_text.models.core.ipynb. # %% ../../../nbs/33_text.models.core.ipynb 1 from __future__ import annotations from ...data.all import * from ..core import * from .awdlstm import * # %% auto 0 __all__ = ['LinearDecoder', 'SequentialRNN', 'get_language_model', 'Sen...
8,308
47.30814
113
py
fastai
fastai-master/fastai/text/models/awdlstm.py
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../../nbs/32_text.models.awdlstm.ipynb. # %% ../../../nbs/32_text.models.awdlstm.ipynb 1 from __future__ import annotations from ...data.all import * from ..core import * # %% auto 0 __all__ = ['awd_lstm_lm_config', 'awd_lstm_clas_config', 'dropout_mask', 'RNNDropout', '...
8,529
45.868132
131
py
fastai
fastai-master/dev_nbs/course/crappify.py
from fastai.basics import * from PIL import Image, ImageDraw, ImageFont def resize_to(img, targ_sz, use_min=False): w,h = img.size min_sz = (min if use_min else max)(w,h) ratio = targ_sz/min_sz return int(w*ratio),int(h*ratio) class crappifier(): def __init__(self, path_lr, path_hr): self....
859
33.4
109
py
fastai
fastai-master/nbs/dltest.py
from fastai.torch_basics import * from fastai.data.load import * class RandDL(DataLoader): def create_item(self, s): r = random.random() return r if r<0.95 else stop() if __name__ == "__main__": # It can be reproduced in Linux by uncommenting this line # multiprocessing.set_start_method('s...
434
28
61
py
fastai
fastai-master/nbs/examples/train_imdbclassifier.py
from fastai.basics import * from fastai.callback.all import * from fastai.distributed import * from fastprogress import fastprogress from fastai.callback.mixup import * from fastcore.script import * from fastai.text.all import * torch.backends.cudnn.benchmark = True fastprogress.MAX_COLS = 80 def pr(s): if rank_di...
1,574
37.414634
109
py
fastai
fastai-master/nbs/examples/train_wt2.py
from fastai.basics import * from fastai.text.all import * from fastai.callback.all import * from fastcore.script import * def istitle(line): return len(re.findall(r'^ = [^=]* = $', line)) != 0 def read_file(filename): articles = L() with open(filename, encoding='utf8') as f: lines = f.readlines() ...
2,024
42.085106
127
py
fastai
fastai-master/nbs/examples/dataloader_spawn.py
#!/usr/bin/env python # coding: utf-8 from fastai.vision.all import * def get_data(url, presize, resize): path = untar_data(url) #print(Normalize.from_stats(*imagenet_stats)) return DataBlock( blocks=(ImageBlock, CategoryBlock), get_items=get_image_files, splitter=GrandparentSplitter(vali...
1,124
28.605263
76
py
fastai
fastai-master/nbs/examples/migrating_ignite.py
# The fastai DataLoader is a drop-in replacement for Pytorch's; # no code changes are required other than changing the import line from fastai.data.load import DataLoader import torch from torch import nn from torch.optim import SGD import torch.nn.functional as F from torchvision.transforms import Compose, ToTensor,...
3,837
39.829787
121
py
fastai
fastai-master/nbs/examples/migrating_catalyst.py
# The fastai DataLoader is a drop-in replacement for Pytorch's; # no code changes are required other than changing the import line from fastai.data.load import DataLoader import os,torch from torch.nn import functional as F from catalyst import dl from catalyst.data.cv import ToTensor from catalyst.contrib.datasets i...
1,319
34.675676
109
py
fastai
fastai-master/nbs/examples/mnist_items.py
from fastai.vision.all import * items = get_image_files(untar_data(URLs.MNIST)) splits = GrandparentSplitter(train_name='training', valid_name='testing')(items) tds = Datasets(items, [PILImageBW.create, [parent_label, Categorize()]], splits=splits) if __name__ == '__main__': data = tds.dataloaders(bs=256, after_i...
442
35.916667
87
py
fastai
fastai-master/nbs/examples/migrating_fastai.py
from fastai.vision.all import * from torchvision import datasets, transforms class Net(nn.Sequential): def __init__(self): super().__init__( nn.Conv2d(1, 32, 3, 1), nn.ReLU(), nn.Conv2d(32, 64, 3, 1), nn.MaxPool2d(2), nn.Dropout2d(0.25), Flatten(), nn.Linear(9216, 128), ...
1,183
38.466667
87
py
fastai
fastai-master/nbs/examples/train_imagenette.py
from fastai.basics import * from fastai.vision.all import * from fastai.callback.all import * from fastai.distributed import * from fastprogress import fastprogress from torchvision.models import * from fastai.vision.models.xresnet import * from fastai.callback.mixup import * from fastcore.script import * torch.backen...
4,191
46.636364
117
py
fastai
fastai-master/nbs/examples/migrating_lightning.py
# The fastai DataLoader is a drop-in replacement for Pytorch's; # no code changes are required other than changing the import line from fastai.data.load import DataLoader import os,torch from torch.nn import functional as F from torchvision.datasets import MNIST from torchvision import transforms from pytorch_lightni...
1,622
35.066667
97
py
fastai
fastai-master/nbs/examples/distrib.py
from fastai.vision.all import * from fastai.distributed import * from fastai.vision.models.xresnet import * path = rank0_first(untar_data, URLs.IMAGEWOOF_320) dls = DataBlock( blocks=(ImageBlock, CategoryBlock), splitter=GrandparentSplitter(valid_name='val'), get_items=get_image_files, get_y=parent_label, ...
625
35.823529
86
py
fastai
fastai-master/nbs/examples/distrib_pytorch.py
from fastai.vision.all import * from fastai.distributed import * from torch.utils.data import DataLoader from torchvision import datasets, transforms class Net(nn.Sequential): def __init__(self): super().__init__( nn.Conv2d(1, 32, 3, 1), nn.ReLU(), nn.Conv2d(32, 64, 3, 1), nn.MaxPoo...
1,275
38.875
87
py
fastai
fastai-master/nbs/examples/migrating_pytorch.py
import torch from torch import nn import torch.nn.functional as F from torch.utils.data import DataLoader from torchvision import datasets, transforms class Flatten(nn.Module): def forward(self, x): return x.view(x.size(0), -1) class Net(nn.Sequential): def __init__(self): super().__init__( ...
2,716
38.376812
81
py
fastai
fastai-master/nbs/examples/train_tabular.py
from fastai.basics import * from fastai.tabular.all import * from fastai.callback.all import * from fastai.distributed import * from fastprogress import fastprogress from fastai.callback.mixup import * from fastcore.script import * torch.backends.cudnn.benchmark = True fastprogress.MAX_COLS = 80 def pr(s): if ran...
1,471
32.454545
84
py
fastai
fastai-master/nbs/examples/mnist_blocks.py
from fastai.vision.all import * splitter = GrandparentSplitter(train_name='training', valid_name='testing') mnist = DataBlock(blocks=(ImageBlock(PILImageBW), CategoryBlock), get_items=get_image_files, splitter=splitter, get_y=parent_label) if __name__ == '__main__': data = mnist.dataloaders(unta...
425
34.5
83
py
FEMNIST_pytorch
FEMNIST_pytorch-master/femnist.py
from torchvision.datasets import MNIST, utils from PIL import Image import os.path import torch class FEMNIST(MNIST): """ This dataset is derived from the Leaf repository (https://github.com/TalwalkarLab/leaf) pre-processing of the Extended MNIST dataset, grouping examples by writer. Details about Lea...
2,438
36.523077
110
py
LITE
LITE-main/src/tf_dataset_reader.py
import tensorflow as tf import tensorflow_datasets as tfds import torch import torchvision.transforms as T from PIL import Image import numpy as np class TfDatasetReader: def __init__(self, dataset, task, context_batch_size, target_batch_size, path_to_datasets, image_size, device): self.dataset = dataset ...
6,764
38.104046
115
py
LITE
LITE-main/src/efficientnet_utils.py
""" The code in this file is substantially based on the code from "A PyTorch implementation of EfficientNet" by lukemelas that can be found here: https://github.com/lukemelas/EfficientNet-PyTorch """ """Helper functions for building the model and for loading model parameters. These helper functions are built to mir...
25,146
39.494364
130
py
LITE
LITE-main/src/set_encoder.py
import torch import torch.nn as nn """ Classes and functions required for Set encoding in adaptation networks. Many of the ideas and classes here are closely related to DeepSets (https://arxiv.org/abs/1703.06114). """ def mean_pooling(x): return torch.mean(x, dim=0, keepdim=True) class SetEncoder(nn.M...
2,669
32.797468
115
py
LITE
LITE-main/src/features.py
import torch import torch.nn as nn from efficientnet import film_efficientnet, film_efficientnet_b0_84 def create_feature_extractor(args): if args.image_size == 84: feature_extractor = film_efficientnet_b0_84(args.pretrained_model_path) else: feature_extractor = film_efficientnet("efficientnet...
6,618
38.634731
129
py
LITE
LITE-main/src/efficientnet.py
""" The code in this file is substantially based on the code from "A PyTorch implementation of EfficientNet" by lukemelas that can be found here: https://github.com/lukemelas/EfficientNet-PyTorch """ """Model and module class for EfficientNet. They are built to mirror those in the official TensorFlow implementation...
22,768
38.736475
144
py
LITE
LITE-main/src/utils.py
import os import torch import torch.nn.functional as F import numpy as np from enum import Enum import sys import math class MetaLearningState(Enum): META_TRAIN = 0 META_TEST = 1 class ValidationAccuracies: """ Determines if an evaluation on the validation set is better than the best so far. In ...
5,276
35.393103
136
py
LITE
LITE-main/src/model.py
import torch import numpy as np import torch.nn as nn from config_networks import ConfigureNetworks from mahalanonbis import MahalanobisPredictor from set_encoder import mean_pooling class FewShotClassifier(nn.Module): def __init__(self, args, logger, device): super(FewShotClassifier, self).__init__() ...
6,282
51.798319
122
py
LITE
LITE-main/src/run.py
import torch import numpy as np import argparse import os from utils import Logger, LogFiles, ValidationAccuracies, cross_entropy_loss, compute_accuracy, MetaLearningState,\ shuffle from model import FewShotClassifier from dataset import get_dataset_reader from tf_dataset_reader import TfDatasetReader from image_fo...
25,859
52.987474
126
py
LITE
LITE-main/src/mahalanonbis.py
import torch """ The code in this file is substantially based on the code for "Improved Few-Shot Visual Classification" by Peyman Bateni, Raghav Goyal, Vaden Masrani1, Frank Wood, and Leonid Sigal that can be found here: https://github.com/peymanbateni/simple-cnaps """ class MahalanobisPredictor: def __init__(sel...
4,701
46.02
118
py
LITE
LITE-main/src/image_folder_reader.py
import torch from torchvision.datasets import ImageFolder import torchvision.transforms as T import numpy as np class ImageFolderReader: def __init__(self, path_to_images, context_batch_size, target_batch_size, image_size, device, train_fraction=0.7, val_fraction=0.1, test=0.2): self.devi...
3,305
34.170213
114
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/main_molecules_graph_regression.py
""" IMPORTING LIBS """ import dgl import numpy as np import os import socket import time import random import glob import argparse, json import pickle import re import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.utils.data import DataLoader from tensor...
19,964
41.478723
202
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/main_TSP_edge_classification.py
""" IMPORTING LIBS """ import dgl import numpy as np import os import socket import time import random import glob import argparse, json import pickle import re import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.utils.data import DataLoader from tensor...
18,702
39.836245
202
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/main_TUs_graph_classification.py
""" IMPORTING LIBS """ import dgl import numpy as np import os import socket import time import random import glob import argparse, json import re import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.utils.data import DataLoader from tensorboardX import ...
20,561
43.029979
202
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/main_superpixels_graph_classification.py
""" IMPORTING LIBS """ import dgl import numpy as np import os import socket import time import random import glob import argparse, json import pickle import re import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.utils.data import DataLoader from tensor...
18,866
41.113839
202
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/main_SBMs_node_classification.py
""" IMPORTING LIBS """ import dgl import numpy as np import os import socket import time import random import glob import argparse, json import pickle import re import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.utils.data import DataLoader from tensor...
19,778
40.552521
202
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/SBMs_node_classification/bi_gcn_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl import numpy as np """ GCN: Graph Convolutional Networks Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR 2017) http://arxiv.org/abs/1609.02907 """ from layers.gcn_layer import ...
4,566
34.96063
140
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/SBMs_node_classification/bi_gated_gcn_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl import numpy as np """ ResGatedGCN: Residual Gated Graph ConvNets An Experimental Study of Neural Networks for Variable Graphs (Xavier Bresson and Thomas Laurent, ICLR 2018) https://arxiv.org/pdf/1711.07553v2.pdf """ from layers...
18,704
41.319005
147
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/SBMs_node_classification/gcn_net_for_Eval.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl import numpy as np """ GCN: Graph Convolutional Networks Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR 2017) http://arxiv.org/abs/1609.02907 """ from layers.gcn_layer import ...
2,684
33.87013
109
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/SBMs_node_classification/bi_gcn_net_for_Eval.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl import numpy as np """ GCN: Graph Convolutional Networks Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR 2017) http://arxiv.org/abs/1609.02907 """ from layers.gcn_layer import ...
4,752
35.007576
140
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/SBMs_node_classification/bi_graphsage_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ GraphSAGE: William L. Hamilton, Rex Ying, Jure Leskovec, Inductive Representation Learning on Large Graphs (NeurIPS 2017) https://cs.stanford.edu/people/jure/pubs/graphsage-nips17.pdf """ from layers.graphsage_layer import...
4,819
37.56
135
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/SBMs_node_classification/bi_gat_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ GAT: Graph Attention Network Graph Attention Networks (Veličković et al., ICLR 2018) https://arxiv.org/abs/1710.10903 """ from layers.gat_layer import GATLayer from layers.bi_gat_layer import biGATLayer from layers.mlp_reado...
4,771
37.796748
135
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/superpixels_graph_classification/bi_gcn_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ GCN: Graph Convolutional Networks Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR 2017) http://arxiv.org/abs/1609.02907 """ from layers.gcn_layer import GCNLayer from layer...
4,128
41.132653
140
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/superpixels_graph_classification/bi_gated_gcn_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ ResGatedGCN: Residual Gated Graph ConvNets An Experimental Study of Neural Networks for Variable Graphs (Xavier Bresson and Thomas Laurent, ICLR 2018) https://arxiv.org/pdf/1711.07553v2.pdf """ from layers.gated_gcn_layer im...
13,454
41.850318
149
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/superpixels_graph_classification/bi_graphsage_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ GraphSAGE: William L. Hamilton, Rex Ying, Jure Leskovec, Inductive Representation Learning on Large Graphs (NeurIPS 2017) https://cs.stanford.edu/people/jure/pubs/graphsage-nips17.pdf """ from layers.graphsage_layer import...
4,447
40.962264
135
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/superpixels_graph_classification/bi_gat_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl.function as fn import dgl """ GAT: Graph Attention Network Graph Attention Networks (Veličković et al., ICLR 2018) https://arxiv.org/abs/1710.10903 """ from layers.gat_layer import GATLayer from layers.bi_gat_layer import biGATL...
4,422
40.726415
135
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/TUs_graph_classification/bi_gcn_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ GCN: Graph Convolutional Networks Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR 2017) http://arxiv.org/abs/1609.02907 """ from layers.gcn_layer import GCNLayer from layer...
4,137
40.79798
140
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/TUs_graph_classification/bi_gated_gcn_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ ResGatedGCN: Residual Gated Graph ConvNets An Experimental Study of Neural Networks for Variable Graphs (Xavier Bresson and Thomas Laurent, ICLR 2018) https://arxiv.org/pdf/1711.07553v2.pdf """ from layers.gated_gcn_layer im...
4,223
39.228571
135
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/TUs_graph_classification/bi_graphsage_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ GraphSAGE: William L. Hamilton, Rex Ying, Jure Leskovec, Inductive Representation Learning on Large Graphs (NeurIPS 2017) https://cs.stanford.edu/people/jure/pubs/graphsage-nips17.pdf """ from layers.graphsage_layer import...
4,412
40.632075
135
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/TUs_graph_classification/bi_gat_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ GAT: Graph Attention Network Graph Attention Networks (Veličković et al., ICLR 2018) https://arxiv.org/abs/1710.10903 """ from layers.gat_layer import CustomGATLayer as GATLayer from layers.bi_gat_layer import biGATLayer fro...
4,427
41.171429
135
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/TSP_edge_classification/bi_gcn_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ GCN: Graph Convolutional Networks Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR 2017) http://arxiv.org/abs/1609.02907 """ from layers.gcn_layer import GCNLayer from layer...
4,101
40.857143
140
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/TSP_edge_classification/bi_gated_gcn_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ ResGatedGCN: Residual Gated Graph ConvNets An Experimental Study of Neural Networks for Variable Graphs (Xavier Bresson and Thomas Laurent, ICLR 2018) https://arxiv.org/pdf/1711.07553v2.pdf """ from layers.gated_gcn_layer im...
14,061
41.741641
149
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/TSP_edge_classification/bi_graphsage_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ GraphSAGE: William L. Hamilton, Rex Ying, Jure Leskovec, Inductive Representation Learning on Large Graphs (NeurIPS 2017) https://cs.stanford.edu/people/jure/pubs/graphsage-nips17.pdf """ from layers.graphsage_layer import...
4,353
40.865385
135
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/TSP_edge_classification/bi_gat_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ GAT: Graph Attention Network Graph Attention Networks (Veličković et al., ICLR 2018) https://arxiv.org/abs/1710.10903 """ from layers.gat_layer import CustomGATLayer as GATLayer from layers.bi_gat_layer import biGATLayer fro...
4,856
40.161017
135
py
bi-MP-HyeokjinK
bi-MP-HyeokjinK/nets/molecules_graph_regression/bi_gcn_net.py
import torch import torch.nn as nn import torch.nn.functional as F import dgl """ GCN: Graph Convolutional Networks Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks (ICLR 2017) http://arxiv.org/abs/1609.02907 """ from layers.bi_gcn_layer import biGCNLayer from ...
4,313
41.294118
135
py