id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
13,600 | fastai/fastai | fastai_fastai/fastai/text/learner.py | fastai.text.learner.TextLearner | @delegates(Learner.__init__)
class TextLearner(Learner):
"""Basic class for a `Learner` in NLP."""
def __init__(self, dls: DataLoaders, model, alpha: float=2.0, beta: float=1.0, moms: tuple=(0.8, 0.7, 0.8), **kwargs):
super().__init__(dls, model, moms=moms, **kwargs)
self.add_cbs(rnn_cbs(alpha,... | @delegates(Learner.__init__)
class TextLearner(Learner):
'''Basic class for a `Learner` in NLP.'''
def __init__(self, dls: DataLoaders, model, alpha: float=2.0, beta: float=1.0, moms: tuple=(0.8, 0.7, 0.8), **kwargs):
pass
def save_encoder(self, file: str):
'''Save the encoder to `file` in... | 8 | 4 | 11 | 0 | 11 | 4 | 3 | 0.38 | 1 | 7 | 1 | 1 | 5 | 3 | 5 | 5 | 65 | 4 | 56 | 36 | 28 | 21 | 41 | 12 | 35 | 3 | 1 | 1 | 13 |
13,601 | fastai/fastai | fastai_fastai/fastai/text/models/awdlstm.py | fastai.text.models.awdlstm.AWD_LSTM | class AWD_LSTM(Module):
"""AWD-LSTM inspired by https://arxiv.org/abs/1708.02182"""
initrange = 0.1
def __init__(self, vocab_sz: int, emb_sz: int, n_hid: int, n_layers: int, pad_token: int=1, hidden_p: float=0.2, input_p: float=0.6, embed_p: float=0.1, weight_p: float=0.5, bidir: bool=False):
store... | class AWD_LSTM(Module):
'''AWD-LSTM inspired by https://arxiv.org/abs/1708.02182'''
def __init__(self, vocab_sz: int, emb_sz: int, n_hid: int, n_layers: int, pad_token: int=1, hidden_p: float=0.2, input_p: float=0.6, embed_p: float=0.1, weight_p: float=0.5, bidir: bool=False):
pass
def forward(sel... | 8 | 4 | 8 | 0 | 7 | 2 | 3 | 0.26 | 1 | 10 | 3 | 0 | 7 | 8 | 7 | 7 | 66 | 8 | 54 | 36 | 35 | 14 | 45 | 25 | 37 | 6 | 1 | 2 | 19 |
13,602 | fastai/fastai | fastai_fastai/fastai/text/models/awdlstm.py | fastai.text.models.awdlstm.EmbeddingDropout | class EmbeddingDropout(Module):
"""Apply dropout with probability `embed_p` to an embedding layer `emb`."""
def __init__(self, emb: nn.Embedding, embed_p: float):
self.emb, self.embed_p = (emb, embed_p)
def forward(self, words, scale=None):
if self.training and self.embed_p != 0:
... | class EmbeddingDropout(Module):
'''Apply dropout with probability `embed_p` to an embedding layer `emb`.'''
def __init__(self, emb: nn.Embedding, embed_p: float):
pass
def forward(self, words, scale=None):
pass | 3 | 1 | 7 | 0 | 7 | 1 | 2 | 0.2 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 2 | 18 | 2 | 15 | 10 | 9 | 3 | 12 | 7 | 9 | 3 | 1 | 1 | 4 |
13,603 | fastai/fastai | fastai_fastai/fastai/text/models/awdlstm.py | fastai.text.models.awdlstm.RNNDropout | class RNNDropout(Module):
"""Dropout with probability `p` that is consistent on the seq_len dimension."""
def __init__(self, p: float=0.5):
self.p = p
def forward(self, x):
if not self.training or self.p == 0.0:
return x
return x * dropout_mask(x.data, (x.size(0), 1, *x... | class RNNDropout(Module):
'''Dropout with probability `p` that is consistent on the seq_len dimension.'''
def __init__(self, p: float=0.5):
pass
def forward(self, x):
pass | 3 | 1 | 2 | 0 | 2 | 0 | 2 | 0.2 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 2 | 7 | 1 | 5 | 3 | 3 | 1 | 7 | 4 | 4 | 2 | 1 | 1 | 3 |
13,604 | fastai/fastai | fastai_fastai/fastai/text/models/awdlstm.py | fastai.text.models.awdlstm.WeightDropout | class WeightDropout(Module):
"""A module that wraps another layer in which some weights will be replaced by 0 during training."""
def __init__(self, module: nn.Module, weight_p: float, layer_names: str | MutableSequence='weight_hh_l0'):
self.module, self.weight_p, self.layer_names = (module, weight_p, ... | class WeightDropout(Module):
'''A module that wraps another layer in which some weights will be replaced by 0 during training.'''
def __init__(self, module: nn.Module, weight_p: float, layer_names: str | MutableSequence='weight_hh_l0'):
pass
def _setweights(self):
'''Apply dropout to the r... | 6 | 2 | 7 | 0 | 6 | 1 | 2 | 0.23 | 1 | 5 | 0 | 0 | 5 | 4 | 5 | 5 | 40 | 5 | 31 | 18 | 22 | 7 | 30 | 14 | 24 | 3 | 1 | 2 | 11 |
13,605 | fastai/fastai | fastai_fastai/fastai/text/models/core.py | fastai.text.models.core.LinearDecoder | class LinearDecoder(Module):
"""To go on top of a RNNCore module and create a Language Model."""
initrange = 0.1
def __init__(self, n_out: int, n_hid: int, output_p: float=0.1, tie_encoder: nn.Module=None, bias: bool=True):
self.decoder = nn.Linear(n_hid, n_out, bias=bias)
self.decoder.weig... | class LinearDecoder(Module):
'''To go on top of a RNNCore module and create a Language Model.'''
def __init__(self, n_out: int, n_hid: int, output_p: float=0.1, tie_encoder: nn.Module=None, bias: bool=True):
pass
def forward(self, input):
pass | 3 | 1 | 8 | 0 | 8 | 3 | 2 | 0.35 | 1 | 4 | 1 | 0 | 2 | 2 | 2 | 2 | 20 | 2 | 17 | 13 | 8 | 6 | 13 | 7 | 10 | 3 | 1 | 1 | 4 |
13,606 | fastai/fastai | fastai_fastai/fastai/text/models/core.py | fastai.text.models.core.PoolingLinearClassifier | class PoolingLinearClassifier(Module):
"""Create a linear classifier with pooling"""
def __init__(self, dims: list, ps: list, bptt: int, y_range: tuple=None):
if len(ps) != len(dims) - 1:
raise ValueError('Number of layers and dropout values do not match.')
acts = [nn.ReLU(inplace=T... | class PoolingLinearClassifier(Module):
'''Create a linear classifier with pooling'''
def __init__(self, dims: list, ps: list, bptt: int, y_range: tuple=None):
pass
def forward(self, input):
pass | 3 | 1 | 9 | 0 | 9 | 2 | 2 | 0.28 | 1 | 6 | 1 | 0 | 2 | 2 | 2 | 2 | 20 | 1 | 18 | 14 | 10 | 5 | 15 | 9 | 12 | 3 | 1 | 1 | 4 |
13,607 | fastai/fastai | fastai_fastai/fastai/text/models/core.py | fastai.text.models.core.SentenceEncoder | class SentenceEncoder(Module):
"""Create an encoder over `module` that can process a full sentence."""
def __init__(self, bptt: int, module: nn.Module, pad_idx: int=1, max_len: int=None):
store_attr('bptt,module,pad_idx,max_len')
def reset(self):
getcallable(self.module, 'reset')()
de... | class SentenceEncoder(Module):
'''Create an encoder over `module` that can process a full sentence.'''
def __init__(self, bptt: int, module: nn.Module, pad_idx: int=1, max_len: int=None):
pass
def reset(self):
pass
def forward(self, input):
pass | 4 | 1 | 8 | 0 | 7 | 2 | 2 | 0.26 | 1 | 2 | 0 | 0 | 3 | 0 | 3 | 3 | 27 | 2 | 23 | 15 | 15 | 6 | 19 | 9 | 15 | 3 | 1 | 2 | 5 |
13,608 | fastai/fastai | fastai_fastai/fastai/text/models/core.py | fastai.text.models.core.SequentialRNN | class SequentialRNN(nn.Sequential):
"""A sequential module that passes the reset call to its children."""
def reset(self):
for c in self.children():
getcallable(c, 'reset')() | class SequentialRNN(nn.Sequential):
'''A sequential module that passes the reset call to its children.'''
def reset(self):
pass | 2 | 1 | 2 | 0 | 2 | 0 | 2 | 0.33 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 4 | 0 | 3 | 3 | 1 | 1 | 4 | 3 | 2 | 2 | 1 | 1 | 2 |
13,609 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.ArrayBase | class ArrayBase(ndarray):
"""An `ndarray` that can modify casting behavior"""
@classmethod
def _before_cast(cls, x):
return x if isinstance(x, ndarray) else array(x) | class ArrayBase(ndarray):
'''An `ndarray` that can modify casting behavior'''
@classmethod
def _before_cast(cls, x):
pass | 3 | 1 | 1 | 0 | 1 | 0 | 2 | 0.33 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 4 | 0 | 3 | 3 | 1 | 1 | 3 | 2 | 1 | 2 | 1 | 0 | 2 |
13,610 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.ArrayImage | class ArrayImage(ArrayImageBase):
"""An array representing an image"""
pass | class ArrayImage(ArrayImageBase):
'''An array representing an image'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 2 | 3 | 0 | 2 | 1 | 1 | 1 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
13,611 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.ArrayImageBW | class ArrayImageBW(ArrayImage):
"""An array representing an image"""
_show_args = {'cmap': 'Greys'} | class ArrayImageBW(ArrayImage):
'''An array representing an image'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 3 | 0 | 2 | 2 | 1 | 1 | 2 | 2 | 1 | 0 | 4 | 0 | 0 |
13,612 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.ArrayImageBase | class ArrayImageBase(ArrayBase):
"""Base class for arrays representing images"""
_show_args = {'cmap': 'viridis'}
def show(self, ctx=None, **kwargs):
return show_image(self, ctx=ctx, **{**self._show_args, **kwargs}) | class ArrayImageBase(ArrayBase):
'''Base class for arrays representing images'''
def show(self, ctx=None, **kwargs):
pass | 2 | 1 | 2 | 0 | 2 | 0 | 1 | 0.25 | 1 | 0 | 0 | 2 | 1 | 0 | 1 | 2 | 5 | 0 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 2 | 0 | 1 |
13,613 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.ArrayMask | class ArrayMask(ArrayImageBase):
"""An array representing an image mask"""
_show_args = {'alpha': 0.5, 'cmap': 'tab20', 'interpolation': 'nearest'} | class ArrayMask(ArrayImageBase):
'''An array representing an image mask'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 3 | 0 | 2 | 2 | 1 | 1 | 2 | 2 | 1 | 0 | 3 | 0 | 0 |
13,614 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.Chunks | class Chunks:
"""Slice and int indexing into a list of lists"""
def __init__(self, chunks, lens=None):
self.chunks = chunks
self.lens = L(map(len, self.chunks) if lens is None else lens)
self.cumlens = np.cumsum(0 + self.lens)
self.totlen = self.cumlens[-1]
def __getitem__(... | class Chunks:
'''Slice and int indexing into a list of lists'''
def __init__(self, chunks, lens=None):
pass
def __getitem__(self, i):
pass
def getslice(self, i):
pass
def doc_idx(self, i):
pass | 5 | 1 | 5 | 0 | 5 | 0 | 3 | 0.09 | 0 | 3 | 0 | 0 | 4 | 4 | 4 | 4 | 26 | 3 | 22 | 16 | 17 | 2 | 26 | 16 | 21 | 4 | 0 | 1 | 10 |
13,615 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.Module | class Module(nn.Module, metaclass=PrePostInitMeta):
"""Same as `nn.Module`, but no need for subclasses to call `super().__init__`"""
def __pre_init__(self, *args, **kwargs):
super().__init__()
def __init__(self):
pass | class Module(nn.Module, metaclass=PrePostInitMeta):
'''Same as `nn.Module`, but no need for subclasses to call `super().__init__`'''
def __pre_init__(self, *args, **kwargs):
pass
def __init__(self):
pass | 3 | 1 | 1 | 0 | 1 | 0 | 1 | 0.33 | 2 | 1 | 0 | 25 | 2 | 0 | 2 | 12 | 4 | 0 | 3 | 3 | 2 | 1 | 5 | 3 | 2 | 1 | 1 | 0 | 2 |
13,616 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.ShowTitle | class ShowTitle:
"""Base class that adds a simple `show`"""
_show_args = {'label': 'text'}
def show(self, ctx=None, **kwargs):
"""Show self"""
return show_title(str(self), ctx=ctx, **merge(self._show_args, kwargs)) | class ShowTitle:
'''Base class that adds a simple `show`'''
def show(self, ctx=None, **kwargs):
'''Show self'''
pass | 2 | 2 | 3 | 0 | 2 | 1 | 1 | 0.5 | 0 | 1 | 0 | 5 | 1 | 0 | 1 | 1 | 6 | 0 | 4 | 3 | 2 | 2 | 4 | 3 | 2 | 1 | 0 | 0 | 1 |
13,617 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TensorBase | class TensorBase(Tensor):
"""A `Tensor` which support subclass pickling, and maintains metadata when casting or after methods"""
debug, _opt = (False, defaultdict(list))
def __new__(cls, x, **kwargs):
res = cast(tensor(x), cls)
for k, v in kwargs.items():
setattr(res, k, v)
... | class TensorBase(Tensor):
'''A `Tensor` which support subclass pickling, and maintains metadata when casting or after methods'''
def __new__(cls, x, **kwargs):
pass
@classmethod
def _before_cast(cls, x):
pass
def __repr__(self):
pass
def __reduce_ex__(self, proto):
... | 17 | 1 | 4 | 0 | 4 | 0 | 2 | 0.03 | 1 | 6 | 0 | 5 | 10 | 2 | 13 | 13 | 73 | 11 | 60 | 33 | 46 | 2 | 64 | 29 | 50 | 6 | 1 | 2 | 27 |
13,618 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TensorCategory | class TensorCategory(TensorBase):
pass | class TensorCategory(TensorBase):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 13 | 1 | 0 | 1 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 2 | 0 | 0 |
13,619 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TensorFlowField | class TensorFlowField(TensorBase):
pass | class TensorFlowField(TensorBase):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 1 | 0 | 1 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 2 | 0 | 0 |
13,620 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TensorImage | class TensorImage(TensorImageBase):
pass | class TensorImage(TensorImageBase):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 | 0 | 0 | 0 | 14 | 1 | 0 | 1 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
13,621 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TensorImageBW | class TensorImageBW(TensorImage):
_show_args = ArrayImageBW._show_args | class TensorImageBW(TensorImage):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 14 | 1 | 0 | 1 | 1 | 1 | 0 | 2 | 2 | 1 | 0 | 4 | 0 | 0 |
13,622 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TensorImageBase | class TensorImageBase(TensorBase):
_show_args = ArrayImageBase._show_args
def show(self, ctx=None, **kwargs):
return show_image(self, ctx=ctx, **{**self._show_args, **kwargs}) | class TensorImageBase(TensorBase):
def show(self, ctx=None, **kwargs):
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 2 | 1 | 0 | 1 | 14 | 4 | 0 | 4 | 3 | 2 | 0 | 4 | 3 | 2 | 1 | 2 | 0 | 1 |
13,623 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TensorMask | class TensorMask(TensorImageBase):
_show_args = ArrayMask._show_args
def show(self, ctx=None, **kwargs):
codes = getattr(self, 'codes', None)
if codes is not None:
kwargs = merge({'vmin': 0, 'vmax': len(codes)}, kwargs)
return super().show(ctx=ctx, **kwargs) | class TensorMask(TensorImageBase):
def show(self, ctx=None, **kwargs):
pass | 2 | 0 | 4 | 0 | 4 | 0 | 2 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 15 | 7 | 1 | 6 | 4 | 4 | 0 | 7 | 4 | 5 | 2 | 3 | 1 | 2 |
13,624 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TensorMultiCategory | class TensorMultiCategory(TensorCategory):
pass | class TensorMultiCategory(TensorCategory):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 1 | 0 | 1 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
13,625 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TitledFloat | class TitledFloat(Float, ShowTitle):
_show_args = {'label': 'text'}
def show(self, ctx=None, **kwargs):
"""Show self"""
return show_title(str(self), ctx=ctx, **merge(self._show_args, kwargs)) | class TitledFloat(Float, ShowTitle):
def show(self, ctx=None, **kwargs):
'''Show self'''
pass | 2 | 1 | 3 | 0 | 2 | 1 | 1 | 0.25 | 2 | 1 | 0 | 0 | 1 | 0 | 1 | 2 | 5 | 0 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
13,626 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TitledInt | class TitledInt(Int, ShowTitle):
_show_args = {'label': 'text'}
def show(self, ctx=None, **kwargs):
"""Show self"""
return show_title(str(self), ctx=ctx, **merge(self._show_args, kwargs)) | class TitledInt(Int, ShowTitle):
def show(self, ctx=None, **kwargs):
'''Show self'''
pass | 2 | 1 | 3 | 0 | 2 | 1 | 1 | 0.25 | 2 | 1 | 0 | 0 | 1 | 0 | 1 | 2 | 5 | 0 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
13,627 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TitledStr | class TitledStr(Str, ShowTitle):
_show_args = {'label': 'text'}
def show(self, ctx=None, **kwargs):
"""Show self"""
return show_title(str(self), ctx=ctx, **merge(self._show_args, kwargs)) | class TitledStr(Str, ShowTitle):
def show(self, ctx=None, **kwargs):
'''Show self'''
pass | 2 | 1 | 3 | 0 | 2 | 1 | 1 | 0.25 | 2 | 1 | 0 | 0 | 1 | 0 | 1 | 2 | 5 | 0 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
13,628 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TitledTensorScalar | class TitledTensorScalar(TensorBase):
"""A tensor containing a scalar that has a `show` method"""
def show(self, **kwargs):
show_title(self.item(), **kwargs) | class TitledTensorScalar(TensorBase):
'''A tensor containing a scalar that has a `show` method'''
def show(self, **kwargs):
pass | 2 | 1 | 1 | 0 | 1 | 0 | 1 | 0.5 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 14 | 3 | 0 | 2 | 2 | 1 | 1 | 3 | 2 | 1 | 1 | 2 | 0 | 1 |
13,629 | fastai/fastai | fastai_fastai/fastai/torch_core.py | fastai.torch_core.TitledTuple | class TitledTuple(fastuple, ShowTitle):
_show_args = {'label': 'text'}
def show(self, ctx=None, **kwargs):
"""Show self"""
return show_title(str(self), ctx=ctx, **merge(self._show_args, kwargs)) | class TitledTuple(fastuple, ShowTitle):
def show(self, ctx=None, **kwargs):
'''Show self'''
pass | 2 | 1 | 3 | 0 | 2 | 1 | 1 | 0.25 | 2 | 1 | 0 | 0 | 1 | 0 | 1 | 2 | 5 | 0 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
13,630 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.AffineCoordTfm | class AffineCoordTfm(RandTransform):
"""Combine and apply affine and coord transforms"""
order, split_idx = (30, None)
def __init__(self, aff_fs: Callable | MutableSequence=None, coord_fs: Callable | MutableSequence=None, size: int | tuple=None, mode='bilinear', pad_mode=PadMode.Reflection, mode_mask='near... | class AffineCoordTfm(RandTransform):
'''Combine and apply affine and coord transforms'''
def __init__(self, aff_fs: Callable | MutableSequence=None, coord_fs: Callable | MutableSequence=None, size: int | tuple=None, mode='bilinear', pad_mode=PadMode.Reflection, mode_mask='nearest', align_corners=None, **kwargs... | 9 | 2 | 5 | 0 | 5 | 1 | 2 | 0.3 | 1 | 9 | 4 | 5 | 8 | 8 | 8 | 11 | 49 | 5 | 40 | 30 | 22 | 12 | 35 | 17 | 26 | 3 | 2 | 1 | 15 |
13,631 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.Brightness | class Brightness(LightingTfm):
def __init__(self, max_lighting: float=0.2, p: float=0.75, draw: float | MutableSequence | Callable=None, batch=False):
"""Apply change in brightness of `max_lighting` to batch of images with probability `p`."""
store_attr()
super().__init__(_BrightnessLogit(m... | class Brightness(LightingTfm):
def __init__(self, max_lighting: float=0.2, p: float=0.75, draw: float | MutableSequence | Callable=None, batch=False):
'''Apply change in brightness of `max_lighting` to batch of images with probability `p`.'''
pass | 2 | 1 | 9 | 0 | 8 | 5 | 1 | 0.56 | 1 | 4 | 1 | 0 | 1 | 0 | 1 | 9 | 10 | 0 | 9 | 7 | 2 | 5 | 4 | 2 | 2 | 1 | 4 | 0 | 1 |
13,632 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.Contrast | class Contrast(LightingTfm):
"""Apply change in contrast of `max_lighting` to batch of images with probability `p`."""
def __init__(self, max_lighting=0.2, p=0.75, draw: float | MutableSequence | Callable=None, batch=False):
store_attr()
super().__init__(_ContrastLogit(max_lighting, p, draw, ba... | class Contrast(LightingTfm):
'''Apply change in contrast of `max_lighting` to batch of images with probability `p`.'''
def __init__(self, max_lighting=0.2, p=0.75, draw: float | MutableSequence | Callable=None, batch=False):
pass | 2 | 1 | 8 | 0 | 8 | 3 | 1 | 0.44 | 1 | 4 | 1 | 0 | 1 | 0 | 1 | 9 | 10 | 0 | 9 | 7 | 2 | 4 | 4 | 2 | 2 | 1 | 4 | 0 | 1 |
13,633 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.CropPad | @delegates()
class CropPad(DisplayedTransform):
"""Center crop or pad an image to `size`"""
order = 0
def __init__(self, size: int | tuple, pad_mode: PadMode=PadMode.Zeros, **kwargs):
size = _process_sz(size)
store_attr()
super().__init__(**kwargs)
def encodes(self, x: Image.Im... | @delegates()
class CropPad(DisplayedTransform):
'''Center crop or pad an image to `size`'''
def __init__(self, size: int | tuple, pad_mode: PadMode=PadMode.Zeros, **kwargs):
pass
def encodes(self, x: Image.Image | TensorBBox | TensorPoint):
pass | 4 | 1 | 6 | 0 | 6 | 1 | 1 | 0.21 | 1 | 5 | 2 | 1 | 2 | 1 | 2 | 2 | 16 | 1 | 14 | 11 | 7 | 3 | 10 | 6 | 7 | 1 | 1 | 0 | 2 |
13,634 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.DeterministicDihedral | class DeterministicDihedral(Dihedral):
def __init__(self, size: int | tuple=None, mode: str='bilinear', pad_mode=PadMode.Reflection, align_corners=None):
"""Flip the batch every other call"""
super().__init__(p=1.0, draw=DeterministicDraw(list(range(8))), pad_mode=pad_mode, align_corners=align_corn... | class DeterministicDihedral(Dihedral):
def __init__(self, size: int | tuple=None, mode: str='bilinear', pad_mode=PadMode.Reflection, align_corners=None):
'''Flip the batch every other call'''
pass | 2 | 1 | 8 | 0 | 7 | 5 | 1 | 0.63 | 1 | 7 | 1 | 0 | 1 | 0 | 1 | 13 | 9 | 0 | 8 | 7 | 1 | 5 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
13,635 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.DeterministicDraw | class DeterministicDraw:
def __init__(self, vals):
self.vals, self.count = (vals, -1)
def __call__(self, x):
self.count += 1
return x.new_zeros(x.size(0)) + self.vals[self.count % len(self.vals)] | class DeterministicDraw:
def __init__(self, vals):
pass
def __call__(self, x):
pass | 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 2 | 2 | 6 | 1 | 5 | 3 | 3 | 0 | 6 | 4 | 3 | 1 | 0 | 0 | 2 |
13,636 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.DeterministicFlip | class DeterministicFlip(Flip):
"""Flip the batch every other call"""
def __init__(self, size: int | tuple=None, mode: str='bilinear', pad_mode=PadMode.Reflection, align_corners=True, **kwargs):
super().__init__(p=1.0, draw=DeterministicDraw([0, 1]), mode=mode, pad_mode=pad_mode, align_corners=align_cor... | class DeterministicFlip(Flip):
'''Flip the batch every other call'''
def __init__(self, size: int | tuple=None, mode: str='bilinear', pad_mode=PadMode.Reflection, align_corners=True, **kwargs):
pass | 2 | 1 | 8 | 0 | 8 | 4 | 1 | 0.56 | 1 | 5 | 1 | 0 | 1 | 0 | 1 | 13 | 10 | 0 | 9 | 8 | 1 | 5 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
13,637 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.Dihedral | class Dihedral(AffineCoordTfm):
"""Apply a random dihedral transformation to a batch of images with a probability `p`"""
def __init__(self, p=0.5, draw: int | MutableSequence | Callable=None, size: int | tuple=None, mode: str='bilinear', pad_mode=PadMode.Reflection, batch=False, align_corners=True):
f ... | class Dihedral(AffineCoordTfm):
'''Apply a random dihedral transformation to a batch of images with a probability `p`'''
def __init__(self, p=0.5, draw: int | MutableSequence | Callable=None, size: int | tuple=None, mode: str='bilinear', pad_mode=PadMode.Reflection, batch=False, align_corners=True):
pa... | 2 | 1 | 11 | 0 | 11 | 7 | 1 | 0.67 | 1 | 6 | 0 | 1 | 1 | 0 | 1 | 12 | 13 | 0 | 12 | 11 | 2 | 8 | 4 | 3 | 2 | 1 | 3 | 0 | 1 |
13,638 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.DihedralItem | class DihedralItem(RandTransform):
"""Randomly flip with probability `p`"""
def before_call(self, b, split_idx):
super().before_call(b, split_idx)
self.k = random.randint(0, 7)
def encodes(self, x: (Image.Image, *TensorTypes)):
return x.dihedral(self.k) | class DihedralItem(RandTransform):
'''Randomly flip with probability `p`'''
def before_call(self, b, split_idx):
pass
def encodes(self, x: (Image.Image, *TensorTypes)):
pass | 3 | 1 | 2 | 0 | 2 | 0 | 1 | 0.2 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 5 | 7 | 1 | 5 | 4 | 3 | 1 | 6 | 4 | 3 | 1 | 2 | 0 | 2 |
13,639 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.Flip | class Flip(AffineCoordTfm):
"""Randomly flip a batch of images with a probability `p`"""
def __init__(self, p=0.5, draw: int | MutableSequence | Callable=None, size: int | tuple=None, mode: str='bilinear', pad_mode=PadMode.Reflection, align_corners=True, batch=False):
aff_fs = partial(flip_mat, p=p, dr... | class Flip(AffineCoordTfm):
'''Randomly flip a batch of images with a probability `p`'''
def __init__(self, p=0.5, draw: int | MutableSequence | Callable=None, size: int | tuple=None, mode: str='bilinear', pad_mode=PadMode.Reflection, align_corners=True, batch=False):
pass | 2 | 1 | 11 | 0 | 11 | 7 | 1 | 0.67 | 1 | 6 | 0 | 1 | 1 | 0 | 1 | 12 | 13 | 0 | 12 | 11 | 2 | 8 | 4 | 3 | 2 | 1 | 3 | 0 | 1 |
13,640 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.FlipItem | class FlipItem(RandTransform):
"""Randomly flip with probability `p`"""
def __init__(self, p: float=0.5):
super().__init__(p=p)
def encodes(self, x: (Image.Image, *TensorTypes)):
return x.flip_lr() | class FlipItem(RandTransform):
'''Randomly flip with probability `p`'''
def __init__(self, p: float=0.5):
pass
def encodes(self, x: (Image.Image, *TensorTypes)):
pass | 3 | 1 | 1 | 0 | 1 | 0 | 1 | 0.33 | 1 | 2 | 0 | 0 | 2 | 0 | 2 | 5 | 4 | 0 | 3 | 3 | 2 | 1 | 5 | 3 | 2 | 1 | 2 | 0 | 2 |
13,641 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.HSVTfm | class HSVTfm(SpaceTfm):
"""Apply `fs` to the images in HSV space"""
def __init__(self, fs, **kwargs):
super().__init__(fs, TensorImage.hsv, **kwargs) | class HSVTfm(SpaceTfm):
'''Apply `fs` to the images in HSV space'''
def __init__(self, fs, **kwargs):
pass | 2 | 1 | 2 | 0 | 2 | 0 | 1 | 0.33 | 1 | 2 | 1 | 1 | 1 | 0 | 1 | 8 | 4 | 0 | 3 | 2 | 1 | 1 | 3 | 2 | 1 | 1 | 3 | 0 | 1 |
13,642 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.Hue | class Hue(HSVTfm):
"""Apply change in hue of `max_hue` to batch of images with probability `p`."""
def __init__(self, max_hue: float=0.1, p: float=0.75, draw: float | MutableSequence | Callable=None, batch=False):
super().__init__(_Hue(max_hue, p, draw, batch)) | class Hue(HSVTfm):
'''Apply change in hue of `max_hue` to batch of images with probability `p`.'''
def __init__(self, max_hue: float=0.1, p: float=0.75, draw: float | MutableSequence | Callable=None, batch=False):
pass | 2 | 1 | 7 | 0 | 7 | 4 | 1 | 0.75 | 1 | 4 | 1 | 0 | 1 | 0 | 1 | 9 | 10 | 0 | 8 | 7 | 1 | 6 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
13,643 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.LightingTfm | class LightingTfm(SpaceTfm):
"""Apply `fs` to the logits"""
order = 40
def __init__(self, fs: Callable | MutableSequence, **kwargs):
super().__init__(fs, TensorImage.lighting, **kwargs) | class LightingTfm(SpaceTfm):
'''Apply `fs` to the logits'''
def __init__(self, fs: Callable | MutableSequence, **kwargs):
pass | 2 | 1 | 5 | 0 | 5 | 1 | 1 | 0.29 | 1 | 3 | 1 | 3 | 1 | 0 | 1 | 8 | 8 | 0 | 7 | 6 | 2 | 2 | 4 | 3 | 2 | 1 | 3 | 0 | 1 |
13,644 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.OldRandomCrop | class OldRandomCrop(CropPad):
"""Randomly crop an image to `size`"""
def before_call(self, b, split_idx):
super().before_call(b, split_idx)
w, h = self.orig_sz
if not split_idx:
self.tl = (random.randint(0, w - self.cp_size[0]), random.randint(0, h - self.cp_size[1])) | class OldRandomCrop(CropPad):
'''Randomly crop an image to `size`'''
def before_call(self, b, split_idx):
pass | 2 | 1 | 4 | 0 | 4 | 0 | 2 | 0.2 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 3 | 6 | 0 | 5 | 4 | 3 | 1 | 6 | 4 | 4 | 2 | 2 | 1 | 2 |
13,645 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.RandTransform | class RandTransform(DisplayedTransform):
"""A transform that before_call its state at each `__call__`"""
do, nm, supports, split_idx = (True, None, [], 0)
def __init__(self, p: float=1.0, nm: str=None, before_call: Callable=None, **kwargs):
store_attr('p')
super().__init__(**kwargs)
... | class RandTransform(DisplayedTransform):
'''A transform that before_call its state at each `__call__`'''
def __init__(self, p: float=1.0, nm: str=None, before_call: Callable=None, **kwargs):
pass
def before_call(self, b, split_idx: int):
'''This function can be overridden. Set `self.do` ba... | 4 | 2 | 7 | 0 | 7 | 2 | 1 | 0.26 | 1 | 4 | 0 | 9 | 3 | 0 | 3 | 3 | 27 | 2 | 23 | 17 | 7 | 6 | 11 | 5 | 7 | 2 | 1 | 0 | 4 |
13,646 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.RandomCrop | @delegates()
class RandomCrop(RandTransform):
"""Randomly crop an image to `size`"""
split_idx, order = (None, 1)
def __init__(self, size: int | tuple, **kwargs):
size = _process_sz(size)
store_attr()
super().__init__(**kwargs)
def before_call(self, b, split_idx: int):
... | @delegates()
class RandomCrop(RandTransform):
'''Randomly crop an image to `size`'''
def __init__(self, size: int | tuple, **kwargs):
pass
def before_call(self, b, split_idx: int):
'''Randomly positioning crop if train dataset else center crop'''
pass
def encodes(self, x: Imag... | 5 | 2 | 7 | 0 | 7 | 1 | 2 | 0.17 | 1 | 5 | 2 | 0 | 3 | 3 | 3 | 6 | 27 | 2 | 23 | 18 | 13 | 4 | 17 | 11 | 13 | 4 | 2 | 1 | 6 |
13,647 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.RandomErasing | class RandomErasing(RandTransform):
"""Randomly selects a rectangle region in an image and randomizes its pixels."""
order = 100
def __init__(self, p: float=0.5, sl: float=0.0, sh: float=0.3, min_aspect: float=0.3, max_count: int=1):
store_attr()
super().__init__(p=p)
self.log_ratio... | class RandomErasing(RandTransform):
'''Randomly selects a rectangle region in an image and randomizes its pixels.'''
def __init__(self, p: float=0.5, sl: float=0.0, sh: float=0.3, min_aspect: float=0.3, max_count: int=1):
pass
def _bounds(self, area, img_h, img_w):
pass
def encodes(se... | 4 | 1 | 7 | 0 | 7 | 2 | 1 | 0.32 | 1 | 5 | 1 | 0 | 3 | 1 | 3 | 6 | 25 | 2 | 22 | 17 | 12 | 7 | 16 | 11 | 12 | 1 | 2 | 0 | 3 |
13,648 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.RandomResizedCrop | @delegates()
class RandomResizedCrop(RandTransform):
"""Picks a random scaled crop of an image and resize it to `size`"""
split_idx, order = (None, 1)
def __init__(self, size: int | tuple, min_scale: float=0.08, ratio=(3 / 4, 4 / 3), resamples=(BILINEAR, NEAREST), val_xtra: float=0.14, max_scale: float=1.0... | @delegates()
class RandomResizedCrop(RandTransform):
'''Picks a random scaled crop of an image and resize it to `size`'''
def __init__(self, size: int | tuple, min_scale: float=0.08, ratio=(3 / 4, 4 / 3), resamples=(BILINEAR, NEAREST), val_xtra:
pass
def before_call(self, b, split_idx):
pa... | 5 | 1 | 14 | 0 | 14 | 3 | 3 | 0.2 | 1 | 8 | 3 | 0 | 3 | 7 | 3 | 6 | 47 | 2 | 44 | 28 | 29 | 9 | 34 | 16 | 30 | 6 | 2 | 2 | 10 |
13,649 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.RandomResizedCropGPU | class RandomResizedCropGPU(RandTransform):
"""Picks a random scaled crop of an image and resize it to `size`"""
split_idx, order = (None, 30)
def __init__(self, size, min_scale=0.08, ratio=(3 / 4, 4 / 3), mode='bilinear', valid_scale=1.0, max_scale=1.0, mode_mask='nearest', **kwargs):
if isinstance... | class RandomResizedCropGPU(RandTransform):
'''Picks a random scaled crop of an image and resize it to `size`'''
def __init__(self, size, min_scale=0.08, ratio=(3 / 4, 4 / 3), mode='bilinear', valid_scale=1.0, max_scale=1.0, mode_mask='nearest', **kwargs):
pass
def before_call(self, b, split_idx):
... | 6 | 1 | 7 | 0 | 7 | 1 | 3 | 0.21 | 1 | 8 | 4 | 0 | 5 | 4 | 5 | 8 | 42 | 3 | 38 | 26 | 25 | 8 | 35 | 16 | 29 | 8 | 2 | 2 | 13 |
13,650 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.RatioResize | class RatioResize(DisplayedTransform):
"""Resizes the biggest dimension of an image to `max_sz` maintaining the aspect ratio"""
order = 1
def __init__(self, max_sz: int, resamples=(BILINEAR, NEAREST), **kwargs):
store_attr()
super().__init__(**kwargs)
def encodes(self, x: Image.Image |... | class RatioResize(DisplayedTransform):
'''Resizes the biggest dimension of an image to `max_sz` maintaining the aspect ratio'''
def __init__(self, max_sz: int, resamples=(BILINEAR, NEAREST), **kwargs):
pass
def encodes(self, x: Image.Image | TensorBBox | TensorPoint):
pass | 3 | 1 | 6 | 0 | 6 | 1 | 2 | 0.21 | 1 | 5 | 3 | 0 | 2 | 0 | 2 | 2 | 16 | 1 | 14 | 10 | 7 | 3 | 11 | 6 | 8 | 2 | 1 | 1 | 3 |
13,651 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.Resize | @delegates()
class Resize(RandTransform):
split_idx, mode, mode_mask, order = (None, BILINEAR, NEAREST, 1)
'Resize image to `size` using `method`'
def __init__(self, size: int | tuple, method: ResizeMethod=ResizeMethod.Crop, pad_mode: PadMode=PadMode.Reflection, resamples=(BILINEAR, NEAREST), **kwargs):
... | @delegates()
class Resize(RandTransform):
def __init__(self, size: int | tuple, method: ResizeMethod=ResizeMethod.Crop, pad_mode: PadMode=PadMode.Reflection, resamples=(BILINEAR, NEAREST), **kwargs):
pass
def before_call(self, b, split_idx: int):
pass
def encodes(self, x: Image.Image | Te... | 5 | 0 | 10 | 0 | 10 | 2 | 3 | 0.19 | 1 | 6 | 3 | 0 | 3 | 2 | 3 | 6 | 35 | 3 | 31 | 22 | 18 | 6 | 21 | 12 | 17 | 5 | 2 | 1 | 9 |
13,652 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.Rotate | class Rotate(AffineCoordTfm):
"""Apply a random rotation of at most `max_deg` with probability `p` to a batch of images"""
def __init__(self, max_deg: int=10, p: float=0.5, draw: int | MutableSequence | Callable=None, size: int | tuple=None, mode: str='bilinear', pad_mode=PadMode.Reflection, align_corners: boo... | class Rotate(AffineCoordTfm):
'''Apply a random rotation of at most `max_deg` with probability `p` to a batch of images'''
def __init__(self, max_deg: int=10, p: float=0.5, draw: int | MutableSequence | Callable=None, size: int | tuple=None, mode: str='bilinear', pad_mode=PadMode.Reflection, align_corners: boo... | 2 | 1 | 12 | 0 | 12 | 8 | 1 | 0.69 | 1 | 8 | 0 | 0 | 1 | 0 | 1 | 12 | 14 | 0 | 13 | 12 | 2 | 9 | 4 | 3 | 2 | 1 | 3 | 0 | 1 |
13,653 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.Saturation | class Saturation(LightingTfm):
"""Apply change in saturation of `max_lighting` to batch of images with probability `p`."""
def __init__(self, max_lighting: float=0.2, p: float=0.75, draw: float | MutableSequence | Callable=None, batch: bool=False):
store_attr()
super().__init__(_SaturationLogit... | class Saturation(LightingTfm):
'''Apply change in saturation of `max_lighting` to batch of images with probability `p`.'''
def __init__(self, max_lighting: float=0.2, p: float=0.75, draw: float | MutableSequence | Callable=None, batch: bool=False):
pass | 2 | 1 | 8 | 0 | 8 | 4 | 1 | 0.67 | 1 | 5 | 1 | 0 | 1 | 0 | 1 | 9 | 11 | 0 | 9 | 7 | 2 | 6 | 4 | 2 | 2 | 1 | 4 | 0 | 1 |
13,654 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.SpaceTfm | class SpaceTfm(RandTransform):
"""Apply `fs` to the logits"""
order = 40
def __init__(self, fs: Callable | MutableSequence, space_fn: Callable, **kwargs):
super().__init__(**kwargs)
self.space_fn = space_fn
self.fs = L(fs)
def before_call(self, b, split_idx: int):
self.... | class SpaceTfm(RandTransform):
'''Apply `fs` to the logits'''
def __init__(self, fs: Callable | MutableSequence, space_fn: Callable, **kwargs):
pass
def before_call(self, b, split_idx: int):
pass
def compose(self, tfm: Callable):
'''Compose `self` with another `LightingTransfo... | 5 | 2 | 5 | 0 | 5 | 1 | 2 | 0.27 | 1 | 6 | 1 | 2 | 4 | 3 | 4 | 7 | 27 | 3 | 22 | 19 | 9 | 6 | 16 | 10 | 11 | 3 | 2 | 1 | 6 |
13,655 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.Warp | class Warp(AffineCoordTfm):
"""Apply perspective warping with `magnitude` and `p` on a batch of matrices"""
def __init__(self, magnitude: float=0.2, p: float=0.5, draw_x: float | MutableSequence | Callable=None, draw_y: float | MutableSequence | Callable=None, size: int | tuple=None, mode: str='bilinear', pad_... | class Warp(AffineCoordTfm):
'''Apply perspective warping with `magnitude` and `p` on a batch of matrices'''
def __init__(self, magnitude: float=0.2, p: float=0.5, draw_x: float | MutableSequence | Callable=None, draw_y: float | MutableSequence | Callable=None, size: int | tuple=None, mode: str='bilinear', pad_... | 2 | 1 | 14 | 0 | 14 | 9 | 1 | 0.67 | 1 | 8 | 1 | 0 | 1 | 0 | 1 | 12 | 16 | 0 | 15 | 13 | 3 | 10 | 5 | 3 | 3 | 1 | 3 | 0 | 1 |
13,656 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment.Zoom | class Zoom(AffineCoordTfm):
"""Apply a random zoom of at most `max_zoom` with probability `p` to a batch of images"""
def __init__(self, min_zoom: float=1.0, max_zoom: float=1.1, p: float=0.5, draw: float | MutableSequence | Callable=None, draw_x: float | MutableSequence | Callable=None, draw_y: float | Mutabl... | class Zoom(AffineCoordTfm):
'''Apply a random zoom of at most `max_zoom` with probability `p` to a batch of images'''
def __init__(self, min_zoom: float=1.0, max_zoom: float=1.1, p: float=0.5, draw: float | MutableSequence | Callable=None, draw_x: float | MutableSequence | Callable=None, draw_y: float | Mutabl... | 2 | 1 | 15 | 0 | 15 | 11 | 1 | 0.75 | 1 | 6 | 0 | 0 | 1 | 0 | 1 | 12 | 17 | 0 | 16 | 15 | 2 | 12 | 4 | 3 | 2 | 1 | 3 | 0 | 1 |
13,657 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment._BrightnessLogit | class _BrightnessLogit:
def __init__(self, max_lighting=0.2, p=0.75, draw=None, batch=False):
store_attr()
def _def_draw(self, x):
if not self.batch:
return x.new_empty(x.size(0)).uniform_(0.5 * (1 - self.max_lighting), 0.5 * (1 + self.max_lighting))
return x.new_zeros(x.si... | class _BrightnessLogit:
def __init__(self, max_lighting=0.2, p=0.75, draw=None, batch=False):
pass
def _def_draw(self, x):
pass
def before_call(self, x):
pass
def __call__(self, x):
pass | 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 4 | 3 | 4 | 4 | 11 | 3 | 8 | 6 | 5 | 0 | 11 | 6 | 6 | 2 | 0 | 1 | 5 |
13,658 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment._ContrastLogit | class _ContrastLogit:
def __init__(self, max_lighting=0.2, p=0.75, draw=None, batch=False):
store_attr()
def _def_draw(self, x):
if not self.batch:
res = x.new_empty(x.size(0)).uniform_(math.log(1 - self.max_lighting), -math.log(1 - self.max_lighting))
else:
res... | class _ContrastLogit:
def __init__(self, max_lighting=0.2, p=0.75, draw=None, batch=False):
pass
def _def_draw(self, x):
pass
def before_call(self, x):
pass
def __call__(self, x):
pass | 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 4 | 4 | 4 | 4 | 12 | 3 | 9 | 7 | 6 | 0 | 12 | 7 | 7 | 2 | 0 | 1 | 5 |
13,659 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment._Hue | class _Hue:
def __init__(self, max_hue=0.1, p=0.75, draw=None, batch=False):
store_attr()
def _def_draw(self, x):
if not self.batch:
res = x.new_empty(x.size(0)).uniform_(math.log(1 - self.max_hue), -math.log(1 - self.max_hue))
else:
res = x.new_zeros(x.size(0))... | class _Hue:
def __init__(self, max_hue=0.1, p=0.75, draw=None, batch=False):
pass
def _def_draw(self, x):
pass
def before_call(self, x):
pass
def __call__(self, x):
pass | 5 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 4 | 4 | 4 | 4 | 16 | 3 | 13 | 8 | 9 | 0 | 15 | 8 | 10 | 2 | 0 | 1 | 5 |
13,660 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment._SaturationLogit | class _SaturationLogit:
def __init__(self, max_lighting=0.2, p=0.75, draw=None, batch=False):
store_attr()
def _def_draw(self, x):
if not self.batch:
res = x.new_empty(x.size(0)).uniform_(math.log(1 - self.max_lighting), -math.log(1 - self.max_lighting))
else:
r... | class _SaturationLogit:
def __init__(self, max_lighting=0.2, p=0.75, draw=None, batch=False):
pass
def _def_draw(self, x):
pass
def before_call(self, x):
pass
def __call__(self, x):
pass | 5 | 0 | 3 | 0 | 3 | 0 | 1 | 0.08 | 0 | 0 | 0 | 0 | 4 | 4 | 4 | 4 | 17 | 3 | 13 | 8 | 9 | 1 | 15 | 8 | 10 | 2 | 0 | 1 | 5 |
13,661 | fastai/fastai | fastai_fastai/fastai/vision/augment.py | fastai.vision.augment._WarpCoord | from torch import stack, zeros_like as t0, ones_like as t1
class _WarpCoord:
def __init__(self, magnitude=0.2, p=0.5, draw_x=None, draw_y=None, batch=False):
store_attr()
self.coeffs = None
def _def_draw(self, x):
if not self.batch:
return x.new_empty(x.size(0)).uniform_(-... |
class _WarpCoord:
def __init__(self, magnitude=0.2, p=0.5, draw_x=None, draw_y=None, batch=False):
pass
def _def_draw(self, x):
pass
def before_call(self, x):
pass
def __call__(self, x, invert=False):
pass | 5 | 0 | 4 | 0 | 4 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 4 | 6 | 4 | 4 | 21 | 3 | 18 | 13 | 13 | 0 | 18 | 13 | 13 | 2 | 0 | 1 | 6 |
13,662 | fastai/fastai | fastai_fastai/fastai/vision/core.py | fastai.vision.core.AddMaskCodes | class AddMaskCodes(Transform):
"""Add the code metadata to a `TensorMask`"""
def __init__(self, codes=None):
self.codes = codes
if codes is not None:
self.vocab, self.c = (codes, len(codes))
def decodes(self, o: TensorMask):
if self.codes is not None:
o.code... | class AddMaskCodes(Transform):
'''Add the code metadata to a `TensorMask`'''
def __init__(self, codes=None):
pass
def decodes(self, o: TensorMask):
pass | 3 | 1 | 3 | 0 | 3 | 0 | 2 | 0.14 | 1 | 1 | 1 | 0 | 2 | 3 | 2 | 2 | 9 | 1 | 7 | 5 | 4 | 1 | 9 | 5 | 6 | 2 | 1 | 1 | 4 |
13,663 | fastai/fastai | fastai_fastai/fastai/vision/core.py | fastai.vision.core.BBoxLabeler | class BBoxLabeler(Transform):
def setups(self, dl):
self.vocab = dl.vocab
def decode(self, x, **kwargs):
self.bbox, self.lbls = (None, None)
return self._call('decodes', x, **kwargs)
def decodes(self, x: TensorMultiCategory):
self.lbls = [self.vocab[a] for a in x]
... | class BBoxLabeler(Transform):
def setups(self, dl):
pass
def decode(self, x, **kwargs):
pass
def decodes(self, x: TensorMultiCategory):
pass
def decodes(self, x: TensorMultiCategory):
pass | 5 | 0 | 3 | 0 | 3 | 0 | 2 | 0 | 1 | 3 | 3 | 0 | 4 | 3 | 4 | 4 | 14 | 3 | 11 | 6 | 7 | 0 | 12 | 7 | 7 | 2 | 1 | 0 | 6 |
13,664 | fastai/fastai | fastai_fastai/fastai/vision/core.py | fastai.vision.core.LabeledBBox | class LabeledBBox(L):
"""Basic type for a list of bounding boxes in an image"""
def show(self, ctx=None, **kwargs):
for b, l in zip(self.bbox, self.lbl):
if l != '#na#':
ctx = retain_type(b, self.bbox).show(ctx=ctx, text=l)
return ctx
bbox, lbl = add_props(lambda... | class LabeledBBox(L):
'''Basic type for a list of bounding boxes in an image'''
def show(self, ctx=None, **kwargs):
pass | 2 | 1 | 4 | 0 | 4 | 1 | 3 | 0.33 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 8 | 1 | 6 | 4 | 4 | 2 | 7 | 4 | 5 | 3 | 1 | 2 | 3 |
13,665 | fastai/fastai | fastai_fastai/fastai/vision/core.py | fastai.vision.core.PILBase | from PIL import Image
class PILBase(Image.Image, metaclass=BypassNewMeta):
"""Base class for a Pillow `Image` that can show itself and convert to a Tensor"""
_bypass_type = Image.Image
_show_args = {'cmap': 'viridis'}
_open_args = {'mode': 'RGB'}
@classmethod
def create(cls, fn: Path | str | T... |
class PILBase(Image.Image, metaclass=BypassNewMeta):
'''Base class for a Pillow `Image` that can show itself and convert to a Tensor'''
@classmethod
def create(cls, fn: Path | str | Tensor | ndarray | bytes | Image.Image, **kwargs):
'''Return an Image from `fn`'''
pass
def show(self, c... | 5 | 3 | 4 | 0 | 4 | 1 | 3 | 0.19 | 2 | 5 | 2 | 4 | 2 | 0 | 3 | 3 | 21 | 2 | 16 | 8 | 12 | 3 | 22 | 7 | 18 | 7 | 1 | 1 | 9 |
13,666 | fastai/fastai | fastai_fastai/fastai/vision/core.py | fastai.vision.core.PILImage | class PILImage(PILBase):
"""A RGB Pillow `Image` that can show itself and converts to `TensorImage`"""
pass | class PILImage(PILBase):
'''A RGB Pillow `Image` that can show itself and converts to `TensorImage`'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 3 | 3 | 0 | 2 | 1 | 1 | 1 | 2 | 1 | 1 | 0 | 2 | 0 | 0 |
13,667 | fastai/fastai | fastai_fastai/fastai/vision/core.py | fastai.vision.core.PILImageBW | class PILImageBW(PILImage):
"""A BW Pillow `Image` that can show itself and converts to `TensorImageBW`"""
_show_args, _open_args = ({'cmap': 'Greys'}, {'mode': 'L'}) | class PILImageBW(PILImage):
'''A BW Pillow `Image` that can show itself and converts to `TensorImageBW`'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 3 | 0 | 2 | 2 | 1 | 1 | 2 | 2 | 1 | 0 | 3 | 0 | 0 |
13,668 | fastai/fastai | fastai_fastai/fastai/vision/core.py | fastai.vision.core.PILMask | class PILMask(PILBase):
"""A Pillow `Image` Mask that can show itself and converts to `TensorMask`"""
_open_args, _show_args = ({'mode': 'L'}, {'alpha': 0.5, 'cmap': 'tab20'}) | class PILMask(PILBase):
'''A Pillow `Image` Mask that can show itself and converts to `TensorMask`'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 3 | 0 | 2 | 2 | 1 | 1 | 2 | 2 | 1 | 0 | 2 | 0 | 0 |
13,669 | fastai/fastai | fastai_fastai/fastai/vision/core.py | fastai.vision.core.PointScaler | class PointScaler(Transform):
"""Scale a tensor representing points"""
order = 1
def __init__(self, do_scale=True, y_first=False):
self.do_scale, self.y_first = (do_scale, y_first)
def _grab_sz(self, x):
self.sz = [x.shape[-1], x.shape[-2]] if isinstance(x, Tensor) else x.size
... | class PointScaler(Transform):
'''Scale a tensor representing points'''
def __init__(self, do_scale=True, y_first=False):
pass
def _grab_sz(self, x):
pass
def _get_sz(self, x):
pass
def setups(self, dl):
pass
def encodes(self, x: PILBase | TensorImageBase):
... | 9 | 1 | 2 | 0 | 2 | 0 | 1 | 0.07 | 1 | 3 | 3 | 0 | 8 | 4 | 8 | 8 | 19 | 4 | 14 | 13 | 11 | 1 | 21 | 14 | 12 | 2 | 1 | 1 | 11 |
13,670 | fastai/fastai | fastai_fastai/fastai/vision/core.py | fastai.vision.core.TensorBBox | class TensorBBox(TensorPoint):
"""Basic type for a tensor of bounding boxes in an image"""
@classmethod
def create(cls, x, img_size=None) -> None:
return cls(tensor(x).view(-1, 4).float(), img_size=img_size)
def show(self, ctx=None, **kwargs):
x = self.view(-1, 4)
for b in x:
... | class TensorBBox(TensorPoint):
'''Basic type for a tensor of bounding boxes in an image'''
@classmethod
def create(cls, x, img_size=None) -> None:
pass
def show(self, ctx=None, **kwargs):
pass | 4 | 1 | 3 | 0 | 3 | 0 | 2 | 0.14 | 1 | 0 | 0 | 0 | 1 | 0 | 2 | 4 | 9 | 1 | 7 | 6 | 4 | 1 | 8 | 5 | 5 | 2 | 2 | 1 | 3 |
13,671 | fastai/fastai | fastai_fastai/fastai/vision/core.py | fastai.vision.core.TensorPoint | class TensorPoint(TensorBase):
"""Basic type for points in an image"""
_show_args = dict(s=10, marker='.', c='r')
@classmethod
def create(cls, t, img_size=None) -> None:
"""Convert an array or a list of points `t` to a `Tensor`"""
return cls(tensor(t).view(-1, 2).float(), img_size=img_s... | class TensorPoint(TensorBase):
'''Basic type for points in an image'''
@classmethod
def create(cls, t, img_size=None) -> None:
'''Convert an array or a list of points `t` to a `Tensor`'''
pass
def show(self, ctx=None, **kwargs):
pass | 4 | 2 | 4 | 0 | 4 | 1 | 2 | 0.2 | 1 | 0 | 0 | 1 | 1 | 0 | 2 | 2 | 14 | 2 | 10 | 6 | 6 | 2 | 10 | 5 | 7 | 2 | 1 | 1 | 3 |
13,672 | fastai/fastai | fastai_fastai/fastai/vision/data.py | fastai.vision.data.ImageDataLoaders | import types
class ImageDataLoaders(DataLoaders):
"""Basic wrapper around several `DataLoader`s with factory methods for computer vision problems"""
@classmethod
@delegates(DataLoaders.from_dblock)
def from_folder(cls, path, train='train', valid='valid', valid_pct=None, seed=None, vocab=None, item_tfm... |
class ImageDataLoaders(DataLoaders):
'''Basic wrapper around several `DataLoader`s with factory methods for computer vision problems'''
@classmethod
@delegates(DataLoaders.from_dblock)
def from_folder(cls, path, train='train', valid='valid', valid_pct=None, seed=None, vocab=None, item_tfms=None, batch_... | 22 | 9 | 9 | 0 | 8 | 2 | 2 | 0.18 | 1 | 12 | 5 | 0 | 0 | 0 | 8 | 8 | 91 | 7 | 74 | 37 | 43 | 13 | 34 | 20 | 25 | 5 | 1 | 1 | 18 |
13,673 | fastai/fastai | fastai_fastai/fastai/vision/data.py | fastai.vision.data.SegmentationDataLoaders | class SegmentationDataLoaders(DataLoaders):
"""Basic wrapper around several `DataLoader`s with factory methods for segmentation problems"""
@classmethod
@delegates(DataLoaders.from_dblock)
def from_label_func(cls, path, fnames, label_func, valid_pct=0.2, seed=None, codes=None, item_tfms=None, batch_tfm... | class SegmentationDataLoaders(DataLoaders):
'''Basic wrapper around several `DataLoader`s with factory methods for segmentation problems'''
@classmethod
@delegates(DataLoaders.from_dblock)
def from_label_func(cls, path, fnames, label_func, valid_pct=0.2, seed=None, codes=None, item_tfms=None, batch_tfms... | 4 | 2 | 10 | 0 | 9 | 1 | 1 | 0.17 | 1 | 2 | 2 | 0 | 0 | 0 | 1 | 1 | 14 | 0 | 12 | 6 | 7 | 2 | 5 | 4 | 3 | 1 | 1 | 0 | 1 |
13,674 | fastai/fastai | fastai_fastai/fastai/vision/gan.py | fastai.vision.gan.AdaptiveGANSwitcher | class AdaptiveGANSwitcher(Callback):
"""Switcher that goes back to generator/critic when the loss goes below `gen_thresh`/`crit_thresh`."""
run_after = GANTrainer
def __init__(self, gen_thresh: None | float=None, critic_thresh: None | float=None):
store_attr('gen_thresh,critic_thresh')
def aft... | class AdaptiveGANSwitcher(Callback):
'''Switcher that goes back to generator/critic when the loss goes below `gen_thresh`/`crit_thresh`.'''
def __init__(self, gen_thresh: None | float=None, critic_thresh: None | float=None):
pass
def after_batch(self):
'''Switch the model if necessary.'''
... | 3 | 2 | 6 | 0 | 6 | 2 | 3 | 0.31 | 1 | 1 | 0 | 0 | 2 | 0 | 2 | 7 | 16 | 1 | 13 | 7 | 7 | 4 | 12 | 4 | 9 | 5 | 2 | 2 | 6 |
13,675 | fastai/fastai | fastai_fastai/fastai/vision/gan.py | fastai.vision.gan.AdaptiveLoss | class AdaptiveLoss(Module):
"""Expand the `target` to match the `output` size before applying `crit`."""
def __init__(self, crit: Callable):
self.crit = crit
def forward(self, output: Tensor, target: Tensor):
return self.crit(output, target[:, None].expand_as(output).float()) | class AdaptiveLoss(Module):
'''Expand the `target` to match the `output` size before applying `crit`.'''
def __init__(self, crit: Callable):
pass
def forward(self, output: Tensor, target: Tensor):
pass | 3 | 1 | 2 | 0 | 2 | 0 | 1 | 0.25 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 14 | 5 | 0 | 4 | 3 | 2 | 1 | 5 | 4 | 2 | 1 | 2 | 0 | 2 |
13,676 | fastai/fastai | fastai_fastai/fastai/vision/gan.py | fastai.vision.gan.AddChannels | class AddChannels(Module):
"""Add `n_dim` channels at the end of the input."""
def __init__(self, n_dim):
self.n_dim = n_dim
def forward(self, x):
return x.view(*list(x.shape) + [1] * self.n_dim) | class AddChannels(Module):
'''Add `n_dim` channels at the end of the input.'''
def __init__(self, n_dim):
pass
def forward(self, x):
pass | 3 | 1 | 1 | 0 | 1 | 0 | 1 | 0.33 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 14 | 4 | 0 | 3 | 3 | 2 | 1 | 5 | 4 | 2 | 1 | 2 | 0 | 2 |
13,677 | fastai/fastai | fastai_fastai/fastai/vision/gan.py | fastai.vision.gan.FixedGANSwitcher | class FixedGANSwitcher(Callback):
"""Switcher to do `n_crit` iterations of the critic then `n_gen` iterations of the generator."""
run_after = GANTrainer
def __init__(self, n_crit: int=1, n_gen: int=1):
store_attr('n_crit,n_gen')
def before_train(self):
self.n_c, self.n_g = (0, 0)
... | class FixedGANSwitcher(Callback):
'''Switcher to do `n_crit` iterations of the critic then `n_gen` iterations of the generator.'''
def __init__(self, n_crit: int=1, n_gen: int=1):
pass
def before_train(self):
pass
def after_batch(self):
'''Switch the model if necessary.'''
... | 4 | 2 | 6 | 0 | 6 | 1 | 2 | 0.2 | 1 | 1 | 0 | 0 | 3 | 2 | 3 | 8 | 24 | 2 | 20 | 10 | 14 | 4 | 18 | 8 | 14 | 5 | 2 | 1 | 7 |
13,678 | fastai/fastai | fastai_fastai/fastai/vision/gan.py | fastai.vision.gan.GANDiscriminativeLR | class GANDiscriminativeLR(Callback):
"""`Callback` that handles multiplying the learning rate by `mult_lr` for the critic."""
run_after = GANTrainer
def __init__(self, mult_lr=5.0):
self.mult_lr = mult_lr
def before_batch(self):
"""Multiply the current lr if necessary."""
if no... | class GANDiscriminativeLR(Callback):
'''`Callback` that handles multiplying the learning rate by `mult_lr` for the critic.'''
def __init__(self, mult_lr=5.0):
pass
def before_batch(self):
'''Multiply the current lr if necessary.'''
pass
def after_batch(self):
'''Put th... | 4 | 3 | 3 | 0 | 2 | 1 | 2 | 0.38 | 1 | 0 | 0 | 0 | 3 | 1 | 3 | 8 | 13 | 2 | 8 | 5 | 5 | 3 | 10 | 6 | 6 | 2 | 2 | 1 | 5 |
13,679 | fastai/fastai | fastai_fastai/fastai/vision/gan.py | fastai.vision.gan.GANLearner | @delegates()
class GANLearner(Learner):
"""A `Learner` suitable for GANs."""
def __init__(self, dls: DataLoaders, generator: nn.Module, critic: nn.Module, gen_loss_func: Callable, crit_loss_func: Callable, switcher: Callback | None=None, gen_first: bool=False, switch_eval: bool=True, show_img: bool=True, clip:... | @delegates()
class GANLearner(Learner):
'''A `Learner` suitable for GANs.'''
def __init__(self, dls: DataLoaders, generator: nn.Module, critic: nn.Module, gen_loss_func: Callable, crit_loss_func: Callable, switcher: Callback | None=None, gen_first: bool=False, switch_eval: bool=True, show_img: bool=True, clip:... | 7 | 3 | 15 | 0 | 14 | 8 | 2 | 0.56 | 1 | 11 | 6 | 0 | 1 | 0 | 3 | 47 | 50 | 2 | 45 | 38 | 11 | 25 | 17 | 8 | 13 | 2 | 2 | 1 | 5 |
13,680 | fastai/fastai | fastai_fastai/fastai/vision/gan.py | fastai.vision.gan.GANLoss | class GANLoss(GANModule):
"""Wrapper around `crit_loss_func` and `gen_loss_func`"""
def __init__(self, gen_loss_func: Callable, crit_loss_func: Callable, gan_model: GANModule):
super().__init__()
store_attr('gen_loss_func,crit_loss_func,gan_model')
def generator(self, output, target):
... | class GANLoss(GANModule):
'''Wrapper around `crit_loss_func` and `gen_loss_func`'''
def __init__(self, gen_loss_func: Callable, crit_loss_func: Callable, gan_model: GANModule):
pass
def generator(self, output, target):
'''Evaluate the `output` with the critic then uses `self.gen_loss_func`... | 4 | 3 | 8 | 0 | 7 | 3 | 1 | 0.43 | 1 | 1 | 0 | 0 | 3 | 2 | 3 | 18 | 28 | 2 | 23 | 19 | 9 | 10 | 13 | 9 | 9 | 1 | 3 | 0 | 3 |
13,681 | fastai/fastai | fastai_fastai/fastai/vision/gan.py | fastai.vision.gan.GANModule | class GANModule(Module):
"""Wrapper around a `generator` and a `critic` to create a GAN."""
def __init__(self, generator: nn.Module=None, critic: nn.Module=None, gen_mode: None | bool=False):
if generator is not None:
self.generator = generator
if critic is not None:
sel... | class GANModule(Module):
'''Wrapper around a `generator` and a `critic` to create a GAN.'''
def __init__(self, generator: nn.Module=None, critic: nn.Module=None, gen_mode: None | bool=False):
pass
def forward(self, *args):
pass
def switch(self, gen_mode: None | bool=None):
'''... | 4 | 2 | 5 | 0 | 5 | 2 | 2 | 0.4 | 1 | 1 | 0 | 1 | 3 | 3 | 3 | 15 | 19 | 2 | 15 | 13 | 5 | 6 | 11 | 7 | 7 | 3 | 2 | 1 | 7 |
13,682 | fastai/fastai | fastai_fastai/fastai/vision/gan.py | fastai.vision.gan.GANTrainer | class GANTrainer(Callback):
"""Callback to handle GAN Training."""
run_after = TrainEvalCallback
def __init__(self, switch_eval: bool=False, clip: None | float=None, beta: float=0.98, gen_first: bool=False, show_img: bool=True):
store_attr('switch_eval,clip,gen_first,show_img')
self.gen_los... | class GANTrainer(Callback):
'''Callback to handle GAN Training.'''
def __init__(self, switch_eval: bool=False, clip: None | float=None, beta: float=0.98, gen_first: bool=False, show_img: bool=True):
pass
def _set_trainable(self):
'''Appropriately set the generator and critic into a trainab... | 9 | 8 | 7 | 0 | 6 | 2 | 2 | 0.58 | 1 | 3 | 1 | 0 | 8 | 8 | 8 | 13 | 79 | 8 | 48 | 24 | 33 | 28 | 44 | 18 | 35 | 4 | 2 | 2 | 17 |
13,683 | fastai/fastai | fastai_fastai/fastai/vision/gan.py | fastai.vision.gan.InvisibleTensor | class InvisibleTensor(TensorBase):
"""TensorBase but show method does nothing"""
def show(self, ctx=None, **kwargs):
return ctx | class InvisibleTensor(TensorBase):
'''TensorBase but show method does nothing'''
def show(self, ctx=None, **kwargs):
pass | 2 | 1 | 1 | 0 | 1 | 0 | 1 | 0.5 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 14 | 3 | 0 | 2 | 2 | 1 | 1 | 3 | 2 | 1 | 1 | 2 | 0 | 1 |
13,684 | fastai/fastai | fastai_fastai/fastai/vision/learner.py | fastai.vision.learner.TimmBody | class TimmBody(nn.Module):
def __init__(self, model, pretrained: bool=True, cut=None, n_in: int=3):
super().__init__()
self.needs_pool = model.default_cfg.get('pool_size', None) is not None
self.model = model if cut is None else cut_model(model, cut)
def forward(self, x):
retur... | class TimmBody(nn.Module):
def __init__(self, model, pretrained: bool=True, cut=None, n_in: int=3):
pass
def forward(self, x):
pass | 3 | 0 | 3 | 0 | 3 | 0 | 2 | 0 | 1 | 3 | 0 | 0 | 2 | 2 | 2 | 12 | 7 | 1 | 6 | 5 | 4 | 0 | 7 | 5 | 4 | 2 | 1 | 0 | 4 |
13,685 | fastai/fastai | fastai_fastai/fastai/vision/models/unet.py | fastai.vision.models.unet.DynamicUnet | class DynamicUnet(SequentialEx):
"""Create a U-Net from a given architecture."""
def __init__(self, encoder, n_out, img_size, blur=False, blur_final=True, self_attention=False, y_range=None, last_cross=True, bottle=False, act_cls=defaults.activation, init=nn.init.kaiming_normal_, norm_type=None, **kwargs):
... | class DynamicUnet(SequentialEx):
'''Create a U-Net from a given architecture.'''
def __init__(self, encoder, n_out, img_size, blur=False, blur_final=True, self_attention=False, y_range=None, last_cross=True, bottle=False, act_cls=defaults.activation, init=nn.init.kaiming_normal_, norm_type=None, **kwargs):
... | 3 | 1 | 20 | 2 | 18 | 1 | 4 | 0.05 | 1 | 11 | 6 | 0 | 2 | 1 | 2 | 20 | 43 | 4 | 37 | 19 | 32 | 2 | 36 | 17 | 33 | 6 | 3 | 1 | 8 |
13,686 | fastai/fastai | fastai_fastai/fastai/vision/models/unet.py | fastai.vision.models.unet.ResizeToOrig | class ResizeToOrig(Module):
"""Merge a shortcut with the result of the module by adding them or concatenating them if `dense=True`."""
def __init__(self, mode='nearest'):
self.mode = mode
def forward(self, x):
if x.orig.shape[-2:] != x.shape[-2:]:
x = F.interpolate(x, x.orig.sh... | class ResizeToOrig(Module):
'''Merge a shortcut with the result of the module by adding them or concatenating them if `dense=True`.'''
def __init__(self, mode='nearest'):
pass
def forward(self, x):
pass | 3 | 1 | 3 | 0 | 3 | 0 | 2 | 0.17 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 14 | 7 | 0 | 6 | 3 | 4 | 1 | 7 | 4 | 4 | 2 | 2 | 1 | 3 |
13,687 | fastai/fastai | fastai_fastai/fastai/vision/models/unet.py | fastai.vision.models.unet.UnetBlock | class UnetBlock(Module):
"""A quasi-UNet block, using `PixelShuffle_ICNR upsampling`."""
@delegates(ConvLayer.__init__)
def __init__(self, up_in_c, x_in_c, hook, final_div=True, blur=False, act_cls=defaults.activation, self_attention=False, init=nn.init.kaiming_normal_, norm_type=None, **kwargs):
s... | class UnetBlock(Module):
'''A quasi-UNet block, using `PixelShuffle_ICNR upsampling`.'''
@delegates(ConvLayer.__init__)
def __init__(self, up_in_c, x_in_c, hook, final_div=True, blur=False, act_cls=defaults.activation, self_attention=False, init=nn.init.kaiming_normal_, norm_type=None, **kwargs):
pa... | 4 | 1 | 10 | 0 | 10 | 0 | 3 | 0.05 | 1 | 3 | 3 | 0 | 2 | 6 | 2 | 14 | 24 | 1 | 22 | 17 | 17 | 1 | 19 | 15 | 16 | 3 | 2 | 1 | 5 |
13,688 | fastai/fastai | fastai_fastai/fastai/vision/models/xresnet.py | fastai.vision.models.xresnet.XResNet | class XResNet(nn.Sequential):
@delegates(ResBlock)
def __init__(self, block, expansion, layers, p=0.0, c_in=3, n_out=1000, stem_szs=(32, 32, 64), widen=1.0, sa=False, act_cls=defaults.activation, ndim=2, ks=3, stride=2, **kwargs):
store_attr('block,expansion,act_cls,ndim,ks')
if ks % 2 == 0:
... | class XResNet(nn.Sequential):
@delegates(ResBlock)
def __init__(self, block, expansion, layers, p=0.0, c_in=3, n_out=1000, stem_szs=(32, 32, 64), widen=1.0, sa=False, act_cls=defaults.activation, ndim=2, ks=3, stride=2, **kwargs):
pass
def _make_blocks(self, layers, block_szs, sa, stride, **kwargs... | 5 | 0 | 10 | 1 | 9 | 0 | 3 | 0 | 1 | 6 | 1 | 0 | 3 | 3 | 3 | 3 | 33 | 4 | 29 | 11 | 23 | 0 | 16 | 7 | 12 | 3 | 1 | 1 | 8 |
13,689 | fastai/fastai | fastai_fastai/fastai/vision/widgets.py | fastai.vision.widgets.ImageClassifierCleaner | from ipywidgets import HBox, VBox, widgets, Button, Checkbox, Dropdown, Layout, Box, Output, Label, FileUpload
@delegates(ImagesCleaner)
class ImageClassifierCleaner(GetAttr):
"""A widget that provides an `ImagesCleaner` for a CNN `Learner`"""
def __init__(self, learn, **kwargs):
vocab = learn.dls.voc... | @delegates(ImagesCleaner)
class ImageClassifierCleaner(GetAttr):
'''A widget that provides an `ImagesCleaner` for a CNN `Learner`'''
def __init__(self, learn, **kwargs):
pass
def _ipython_display_(self):
pass
def on_change_ds(self, change=None):
'''Toggle between training vali... | 5 | 2 | 5 | 0 | 5 | 0 | 1 | 0.13 | 1 | 1 | 1 | 0 | 3 | 6 | 3 | 3 | 18 | 1 | 15 | 11 | 12 | 2 | 16 | 11 | 12 | 1 | 1 | 0 | 3 |
13,690 | fastai/fastai | fastai_fastai/fastai/vision/widgets.py | fastai.vision.widgets.ImagesCleaner | from ipywidgets import HBox, VBox, widgets, Button, Checkbox, Dropdown, Layout, Box, Output, Label, FileUpload
class ImagesCleaner:
"""A widget that displays all images in `fns` along with a `Dropdown`"""
def __init__(self, opts: tuple=(), height: int=128, width: int=256, max_n: int=30):
opts = ('<Kee... |
class ImagesCleaner:
'''A widget that displays all images in `fns` along with a `Dropdown`'''
def __init__(self, opts: tuple=(), height:
pass
def set_fns(self, fns: list):
'''Sets a `thumbnail` and a `Dropdown` menu for each `VBox`'''
pass
def _ipython_display_(self):
... | 7 | 5 | 5 | 0 | 4 | 2 | 1 | 0.38 | 0 | 3 | 0 | 0 | 6 | 5 | 6 | 6 | 33 | 2 | 26 | 19 | 13 | 10 | 18 | 11 | 11 | 1 | 0 | 0 | 6 |
13,691 | fastai/fastai | fastai_fastai/nbs/examples/migrating_catalyst.py | migrating_catalyst.CustomRunner | from torch.nn import functional as F
from catalyst.utils import metrics
from catalyst import dl
class CustomRunner(dl.Runner):
def predict_batch(self, batch):
return self.model(batch[0].to(self.device).view(batch[0].size(0), -1))
def _handle_batch(self, batch):
x, y = batch
y_hat = se... |
class CustomRunner(dl.Runner):
def predict_batch(self, batch):
pass
def _handle_batch(self, batch):
pass | 3 | 0 | 8 | 1 | 7 | 0 | 2 | 0 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 2 | 17 | 3 | 14 | 7 | 12 | 0 | 13 | 7 | 10 | 2 | 1 | 1 | 3 |
13,692 | fastai/fastai | fastai_fastai/nbs/examples/migrating_fastai.py | migrating_fastai.Net | 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), nn.ReLU(), nn.Dropout2d(0.5), nn.Linear(128, 10), nn.LogSoftmax(dim=1)) | class Net(nn.Sequential):
def __init__(self):
pass | 2 | 0 | 6 | 0 | 6 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 7 | 0 | 7 | 2 | 5 | 0 | 3 | 2 | 1 | 1 | 1 | 0 | 1 |
13,693 | fastai/fastai | fastai_fastai/nbs/examples/migrating_lightning.py | migrating_lightning.LitModel | from torchvision import transforms
from torchvision.datasets import MNIST
from lightning import LightningModule
import torch
import os
from fastai.data.load import DataLoader
from torch.nn import functional as F
class LitModel(LightningModule):
def __init__(self):
super().__init__()
self.l1 = torc... |
class LitModel(LightningModule):
def __init__(self):
pass
def forward(self, x):
pass
def training_step(self, batch, batch_idx):
pass
def configure_optimizers(self):
pass
def train_dataloader(self):
pass
def validation_step(self, batch, batch_idx):
... | 9 | 0 | 3 | 0 | 3 | 0 | 1 | 0.04 | 1 | 2 | 1 | 0 | 8 | 1 | 8 | 8 | 34 | 7 | 26 | 19 | 19 | 1 | 28 | 19 | 19 | 1 | 1 | 0 | 8 |
13,694 | fastai/fastai | fastai_fastai/nbs/examples/migrating_pytorch.py | migrating_pytorch.Flatten | from torch import nn
class Flatten(nn.Module):
def forward(self, x):
return x.view(x.size(0), -1) |
class Flatten(nn.Module):
def forward(self, x):
pass | 2 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 1 | 0 | 1 |
13,695 | fastai/fastai | fastai_fastai/nbs/examples/migrating_pytorch.py | migrating_pytorch.Net | from torch import nn
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), nn.ReLU(), nn.Dropout2d(0.5), nn.Linear(128, 10), nn.LogSoftmax(dim=1)) |
class Net(nn.Sequential):
def __init__(self):
pass | 2 | 0 | 6 | 0 | 6 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 1 | 0 | 1 | 1 | 7 | 0 | 7 | 2 | 5 | 0 | 3 | 2 | 1 | 1 | 1 | 0 | 1 |
13,696 | dmlc/xgboost | demo/aft_survival/aft_survival_viz_demo.py | aft_survival_viz_demo.PlotIntermediateModel | import numpy as np
import xgboost as xgb
import matplotlib.pyplot as plt
class PlotIntermediateModel(xgb.callback.TrainingCallback):
"""Custom callback to plot intermediate models."""
def __init__(self) -> None:
super().__init__()
def after_iteration(self, model: xgb.Booster, epoch: int, evals_lo... |
class PlotIntermediateModel(xgb.callback.TrainingCallback):
'''Custom callback to plot intermediate models.'''
def __init__(self) -> None:
pass
def after_iteration(self, model: xgb.Booster, epoch: int, evals_log: xgb.callback.TrainingCallback.EvalsLog) -> bool:
'''Run after training is fi... | 3 | 2 | 16 | 1 | 12 | 3 | 2 | 0.28 | 1 | 5 | 2 | 0 | 2 | 0 | 2 | 2 | 35 | 3 | 25 | 11 | 17 | 7 | 16 | 6 | 13 | 2 | 1 | 0 | 3 |
13,697 | dmlc/xgboost | demo/guide-python/callbacks.py | callbacks.Plotting | from typing import Dict
import numpy as np
import xgboost as xgb
from matplotlib import pyplot as plt
class Plotting(xgb.callback.TrainingCallback):
"""Plot evaluation result during training. Only for demonstration purpose as it's
quite slow to draw using matplotlib.
"""
def __init__(self, rounds: i... |
class Plotting(xgb.callback.TrainingCallback):
'''Plot evaluation result during training. Only for demonstration purpose as it's
quite slow to draw using matplotlib.
'''
def __init__(self, rounds: int) -> None:
pass
def _get_key(self, data: str, metric: str) -> str:
pass
def... | 4 | 2 | 10 | 0 | 9 | 1 | 3 | 0.21 | 1 | 5 | 1 | 0 | 3 | 5 | 3 | 3 | 39 | 4 | 29 | 15 | 23 | 6 | 26 | 13 | 22 | 6 | 1 | 3 | 8 |
13,698 | dmlc/xgboost | demo/nvflare/horizontal/custom/controller.py | controller.XGBoostController | from trainer import SupportedTasks
import xgboost.federated
from nvflare.apis.client import Client
import multiprocessing
from nvflare.apis.impl.controller import Controller, Task
from nvflare.apis.shareable import Shareable
from nvflare.apis.signal import Signal
from nvflare.apis.fl_context import FLContext
class XGB... |
class XGBoostController(Controller):
def __init__(self, port: int, world_size: int, server_key_path: str, server_cert_path: str, client_cert_path: str):
'''Controller for federated XGBoost.
Args:
port: the port for the gRPC server to listen on.
world_size: the number of sit... | 6 | 1 | 9 | 0 | 7 | 2 | 2 | 0.21 | 1 | 4 | 1 | 0 | 5 | 6 | 5 | 5 | 52 | 6 | 38 | 16 | 29 | 8 | 26 | 13 | 20 | 3 | 1 | 1 | 8 |
13,699 | dmlc/xgboost | demo/nvflare/vertical/custom/controller.py | controller.XGBoostController | from nvflare.apis.shareable import Shareable
from trainer import SupportedTasks
from nvflare.apis.fl_context import FLContext
from nvflare.apis.signal import Signal
import xgboost.federated
from nvflare.apis.client import Client
import multiprocessing
from nvflare.apis.impl.controller import Controller, Task
class XGB... |
class XGBoostController(Controller):
def __init__(self, port: int, world_size: int, server_key_path: str, server_cert_path: str, client_cert_path: str):
'''Controller for federated XGBoost.
Args:
port: the port for the gRPC server to listen on.
world_size: the number of sit... | 6 | 1 | 9 | 0 | 7 | 2 | 2 | 0.21 | 1 | 4 | 1 | 0 | 5 | 6 | 5 | 5 | 52 | 6 | 38 | 16 | 29 | 8 | 26 | 13 | 20 | 3 | 1 | 1 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.