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,500
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.ToTensor
class ToTensor(Transform): """Convert item to appropriate tensor class""" order = 5
class ToTensor(Transform): '''Convert item to appropriate tensor class''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
0
3
0
2
2
1
1
2
2
1
0
1
0
0
13,501
fastai/fastai
fastai_fastai/fastai/distributed.py
fastai.distributed.DistributedDL
from .data.load import _FakeLoader, _loaders class DistributedDL(TfmdDL): """A `TfmdDL` which splits a batch into equal size pieces for each worker""" def __init__(self, dl, rank=None, world_size=None, device=None): if rank is None: rank = rank_distrib() if world_size is None: ...
class DistributedDL(TfmdDL): '''A `TfmdDL` which splits a batch into equal size pieces for each worker''' def __init__(self, dl, rank=None, world_size=None, device=None): pass def _broadcast(self, t, rank): '''Broadcasts t from rank `rank` to all other ranks. Returns t so t is same for al...
13
2
5
0
4
1
2
0.24
1
5
1
0
11
12
11
43
56
5
46
24
38
11
49
23
36
6
3
1
19
13,502
fastai/fastai
fastai_fastai/fastai/distributed.py
fastai.distributed.DistributedTrainer
class DistributedTrainer(Callback): """Wrap `model` in `DistributedDataParallel` and `dls` in `DistributedDL`""" order = 11 @delegates(Accelerator, but=_hidden_params) def __init__(self, sync_bn=True, **kwargs): store_attr() self.accelerator = Accelerator(**kwargs) def before_fit(s...
class DistributedTrainer(Callback): '''Wrap `model` in `DistributedDataParallel` and `dls` in `DistributedDL`''' @delegates(Accelerator, but=_hidden_params) def __init__(self, sync_bn=True, **kwargs): pass def before_fit(self): pass def _wrap_dl(self, dl): pass def _ba...
9
1
3
0
3
0
1
0.1
1
2
1
0
7
2
7
12
24
2
21
15
14
2
21
11
13
3
2
1
10
13,503
fastai/fastai
fastai_fastai/fastai/distributed.py
fastai.distributed.ParallelTrainer
from torch.nn.parallel import DistributedDataParallel, DataParallel class ParallelTrainer(Callback): """Wrap a model `DataParallel` automatically""" run_after, run_before = (TrainEvalCallback, Recorder) def __init__(self, device_ids): self.device_ids = device_ids def before_fit(self): ...
class ParallelTrainer(Callback): '''Wrap a model `DataParallel` automatically''' def __init__(self, device_ids): pass def before_fit(self): pass def after_fit(self): pass
4
1
1
0
1
0
1
0.2
1
1
0
0
3
1
3
8
6
0
5
5
4
1
8
6
4
1
2
0
3
13,504
fastai/fastai
fastai_fastai/fastai/fp16_utils.py
fastai.fp16_utils.FP16Model
import torch import torch.nn as nn class FP16Model(nn.Module): """ Convert model to half precision in a batchnorm-safe way. """ def __init__(self, network): super(FP16Model, self).__init__() self.network = convert_network(network, dtype=torch.half) def forward(self, *inputs): ...
class FP16Model(nn.Module): ''' Convert model to half precision in a batchnorm-safe way. ''' def __init__(self, network): pass def forward(self, *inputs): pass
3
1
3
0
3
0
1
0.43
1
2
0
0
2
1
2
12
12
2
7
4
4
3
7
4
4
1
1
0
2
13,505
fastai/fastai
fastai_fastai/fastai/fp16_utils.py
fastai.fp16_utils.tofp16
import torch.nn as nn class tofp16(nn.Module): """ Utility module that implements:: def forward(self, input): return input.half() """ def __init__(self): super(tofp16, self).__init__() def forward(self, input): return input.half()
class tofp16(nn.Module): ''' Utility module that implements:: def forward(self, input): return input.half() ''' def __init__(self): pass def forward(self, input): pass
3
1
2
0
2
0
1
1
1
1
0
0
2
0
2
12
13
3
5
3
2
5
5
3
2
1
1
0
2
13,506
fastai/fastai
fastai_fastai/fastai/interpret.py
fastai.interpret.ClassificationInterpretation
import sklearn.metrics as skm class ClassificationInterpretation(Interpretation): """Interpretation methods for classification models.""" def __init__(self, learn: Learner, dl: DataLoader, losses: TensorBase, act=None): super().__init__(learn, dl, losses, act) self.vocab = self.dl.vocab ...
class ClassificationInterpretation(Interpretation): '''Interpretation methods for classification models.''' def __init__(self, learn: Learner, dl: DataLoader, losses: TensorBase, act=None): pass def confusion_matrix(self): '''Confusion matrix as an `np.ndarray`.''' pass def p...
6
5
13
1
11
3
2
0.25
1
12
3
0
5
2
5
11
70
8
56
35
38
14
43
23
37
6
1
2
11
13,507
fastai/fastai
fastai_fastai/fastai/interpret.py
fastai.interpret.Interpretation
class Interpretation: """Interpretation base class, can be inherited for task specific Interpretation classes""" def __init__(self, learn: Learner, dl: DataLoader, losses: TensorBase, act=None): store_attr() def __getitem__(self, idxs): """Return inputs, preds, targs, decoded outputs, and ...
class Interpretation: '''Interpretation base class, can be inherited for task specific Interpretation classes''' def __init__(self, learn: Learner, dl: DataLoader, losses: TensorBase, act=None): pass def __getitem__(self, idxs): '''Return inputs, preds, targs, decoded outputs, and losses a...
8
6
10
0
10
3
2
0.37
0
10
4
2
5
2
6
6
73
5
59
41
30
22
40
18
33
3
0
1
14
13,508
fastai/fastai
fastai_fastai/fastai/interpret.py
fastai.interpret.SegmentationInterpretation
class SegmentationInterpretation(Interpretation): """Interpretation methods for segmentation models.""" pass
class SegmentationInterpretation(Interpretation): '''Interpretation methods for segmentation models.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
6
3
0
2
1
1
1
2
1
1
0
1
0
0
13,509
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.AdaptiveConcatPool1d
class AdaptiveConcatPool1d(Module): """Layer that concats `AdaptiveAvgPool1d` and `AdaptiveMaxPool1d`""" def __init__(self, size=None): self.size = size or 1 self.ap = nn.AdaptiveAvgPool1d(self.size) self.mp = nn.AdaptiveMaxPool1d(self.size) def forward(self, x): return tor...
class AdaptiveConcatPool1d(Module): '''Layer that concats `AdaptiveAvgPool1d` and `AdaptiveMaxPool1d`''' def __init__(self, size=None): pass def forward(self, x): pass
3
1
3
0
3
0
1
0.17
1
0
0
0
2
3
2
14
7
0
6
6
4
1
7
6
4
1
2
0
2
13,510
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.AdaptiveConcatPool2d
class AdaptiveConcatPool2d(Module): """Layer that concats `AdaptiveAvgPool2d` and `AdaptiveMaxPool2d`""" def __init__(self, size=None): self.size = size or 1 self.ap = nn.AdaptiveAvgPool2d(self.size) self.mp = nn.AdaptiveMaxPool2d(self.size) def forward(self, x): return tor...
class AdaptiveConcatPool2d(Module): '''Layer that concats `AdaptiveAvgPool2d` and `AdaptiveMaxPool2d`''' def __init__(self, size=None): pass def forward(self, x): pass
3
1
3
0
3
0
1
0.17
1
0
0
0
2
3
2
14
7
0
6
6
4
1
7
6
4
1
2
0
2
13,511
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.BatchNorm1dFlat
class BatchNorm1dFlat(nn.BatchNorm1d): """`nn.BatchNorm1d`, but first flattens leading dimensions""" def forward(self, x): if x.dim() == 2: return super().forward(x) *f, l = x.shape x = x.contiguous().view(-1, l) return super().forward(x).view(*f, l)
class BatchNorm1dFlat(nn.BatchNorm1d): '''`nn.BatchNorm1d`, but first flattens leading dimensions''' def forward(self, x): pass
2
1
5
0
5
0
2
0.17
1
1
0
0
1
0
1
1
7
0
6
3
4
1
7
3
5
2
1
1
2
13,512
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.Cat
class Cat(nn.ModuleList): """Concatenate layers outputs over a given dim""" def __init__(self, layers, dim=1): self.dim = dim super().__init__(layers) def forward(self, x): return torch.cat([l(x) for l in self], dim=self.dim)
class Cat(nn.ModuleList): '''Concatenate layers outputs over a given dim''' def __init__(self, layers, dim=1): pass def forward(self, x): pass
3
1
2
0
2
0
1
0.2
1
1
0
0
2
1
2
2
6
0
5
4
3
1
6
4
3
1
1
0
2
13,513
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.ConvLayer
from torch.nn.utils import weight_norm, spectral_norm class ConvLayer(nn.Sequential): """Create a sequence of convolutional (`ni` to `nf`), ReLU (if `use_activ`) and `norm_type` layers.""" @delegates(nn.Conv2d) def __init__(self, ni, nf, ks=3, stride=1, padding=None, bias=None, ndim=2, norm_type=NormType....
class ConvLayer(nn.Sequential): '''Create a sequence of convolutional (`ni` to `nf`), ReLU (if `use_activ`) and `norm_type` layers.''' @delegates(nn.Conv2d) def __init__(self, ni, nf, ks=3, stride=1, padding=None, bias=None, ndim=2, norm_type=NormType.Batch, bn_1st=True, act_cls=defaults.activation, transp...
3
1
21
0
21
0
12
0.04
1
1
0
0
1
0
1
1
24
0
23
11
19
1
29
9
27
12
1
1
12
13,514
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.Embedding
class Embedding(nn.Embedding): """Embedding layer with truncated normal initialization""" def __init__(self, ni, nf, std=0.01): super().__init__(ni, nf) trunc_normal_(self.weight.data, std=std)
class Embedding(nn.Embedding): '''Embedding layer with truncated normal initialization''' def __init__(self, ni, nf, std=0.01): pass
2
1
3
0
3
0
1
0.25
1
1
0
0
1
0
1
1
5
0
4
2
2
1
4
2
2
1
1
0
1
13,515
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.LinBnDrop
class LinBnDrop(nn.Sequential): """Module grouping `BatchNorm1d`, `Dropout` and `Linear` layers""" def __init__(self, n_in, n_out, bn=True, p=0.0, act=None, lin_first=False): layers = [BatchNorm(n_out if lin_first else n_in, ndim=1)] if bn else [] if p != 0: layers.append(nn.Dropout...
class LinBnDrop(nn.Sequential): '''Module grouping `BatchNorm1d`, `Dropout` and `Linear` layers''' def __init__(self, n_in, n_out, bn=True, p=0.0, act=None, lin_first=False): pass
2
1
7
0
7
0
6
0.13
1
1
0
0
1
0
1
1
9
0
8
4
6
1
10
4
8
6
1
1
6
13,516
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.MergeLayer
class MergeLayer(Module): """Merge a shortcut with the result of the module by adding them or concatenating them if `dense=True`.""" def __init__(self, dense: bool=False): self.dense = dense def forward(self, x): return torch.cat([x, x.orig], dim=1) if self.dense else x + x.orig
class MergeLayer(Module): '''Merge a shortcut with the result of the module by adding them or concatenating them if `dense=True`.''' def __init__(self, dense: bool=False): pass def forward(self, x): pass
3
1
1
0
1
0
2
0.33
1
1
0
0
2
1
2
14
4
0
3
3
2
1
5
4
2
2
2
0
3
13,517
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.MishJit
class MishJit(Module): def forward(self, x): return MishJitAutoFn.apply(x)
class MishJit(Module): def forward(self, x): pass
2
0
1
0
1
0
1
0
1
1
1
0
1
0
1
13
2
0
2
2
1
0
3
2
1
1
2
0
1
13,518
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.MishJitAutoFn
class MishJitAutoFn(torch.autograd.Function): @staticmethod def forward(ctx, x): ctx.save_for_backward(x) return _mish_jit_fwd(x) @staticmethod def backward(ctx, grad_output): x = ctx.saved_variables[0] return _mish_jit_bwd(x, grad_output)
class MishJitAutoFn(torch.autograd.Function): @staticmethod def forward(ctx, x): pass @staticmethod def backward(ctx, grad_output): pass
5
0
3
0
3
0
1
0
1
0
0
0
0
0
2
2
10
1
9
6
4
0
7
4
4
1
1
0
2
13,519
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.NoneReduce
class NoneReduce: """A context manager to evaluate `loss_func` with none reduce.""" def __init__(self, loss_func): self.loss_func, self.old_red = (loss_func, None) def __enter__(self): if hasattr(self.loss_func, 'reduction'): self.old_red = self.loss_func.reduction ...
class NoneReduce: '''A context manager to evaluate `loss_func` with none reduce.''' def __init__(self, loss_func): pass def __enter__(self): pass def __exit__(self, type, value, traceback): pass
4
1
3
0
3
0
2
0.1
0
1
0
0
3
2
3
3
13
2
10
4
7
1
12
5
8
2
0
1
5
13,520
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.ParameterModule
class ParameterModule(Module): """Register a lone parameter `p` in a module.""" def __init__(self, p): self.val = p def forward(self, x): return x
class ParameterModule(Module): '''Register a lone parameter `p` in a module.''' def __init__(self, p): pass def forward(self, x): pass
3
1
1
0
1
0
1
0.33
1
0
0
0
2
1
2
14
4
0
3
3
2
1
5
4
2
1
2
0
2
13,521
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.PartialLambda
class PartialLambda(Lambda): """Layer that applies `partial(func, **kwargs)`""" def __init__(self, func, **kwargs): super().__init__(partial(func, **kwargs)) self.repr = f'{func.__name__}, {kwargs}' def forward(self, x): return self.func(x) def __repr__(self): return f...
class PartialLambda(Lambda): '''Layer that applies `partial(func, **kwargs)`''' def __init__(self, func, **kwargs): pass def forward(self, x): pass def __repr__(self): pass
4
1
2
0
2
0
1
0.17
1
2
0
0
3
1
3
3
8
1
6
5
4
1
8
5
4
1
1
0
3
13,522
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.PixelShuffle_ICNR
class PixelShuffle_ICNR(nn.Sequential): """Upsample by `scale` from `ni` filters to `nf` (default `ni`), using `nn.PixelShuffle`.""" def __init__(self, ni, nf=None, scale=2, blur=False, norm_type=NormType.Weight, act_cls=defaults.activation): super().__init__() nf = ifnone(nf, ni) layer...
class PixelShuffle_ICNR(nn.Sequential): '''Upsample by `scale` from `ni` filters to `nf` (default `ni`), using `nn.PixelShuffle`.''' def __init__(self, ni, nf=None, scale=2, blur=False, norm_type=NormType.Weight, act_cls=defaults.activation): pass
2
1
12
0
12
0
3
0.08
1
2
1
0
1
0
1
1
14
0
13
3
11
1
12
3
10
3
1
1
3
13,523
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.PoolFlatten
class PoolFlatten(nn.Sequential): """Combine `nn.AdaptiveAvgPool2d` and `Flatten`.""" def __init__(self, pool_type=PoolType.Avg): super().__init__(adaptive_pool(pool_type)(1), Flatten())
class PoolFlatten(nn.Sequential): '''Combine `nn.AdaptiveAvgPool2d` and `Flatten`.''' def __init__(self, pool_type=PoolType.Avg): pass
2
1
1
0
1
0
1
0.5
1
2
1
0
1
0
1
1
3
0
2
2
1
1
3
2
1
1
1
0
1
13,524
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.PoolType
class PoolType: Avg, Max, Cat = ('Avg', 'Max', 'Cat')
class PoolType: pass
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
0
2
2
1
0
0
0
0
13,525
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.PooledSelfAttention2d
class PooledSelfAttention2d(Module): """Pooled self attention layer for 2d.""" def __init__(self, n_channels): self.n_channels = n_channels self.query, self.key, self.value = [self._conv(n_channels, c) for c in (n_channels // 8, n_channels // 8, n_channels // 2)] self.out = self._conv(n...
class PooledSelfAttention2d(Module): '''Pooled self attention layer for 2d.''' def __init__(self, n_channels): pass def _conv(self, n_in, n_out): pass def forward(self, x): pass
4
1
5
0
5
0
1
0.06
1
1
1
0
3
6
3
15
19
2
16
13
12
1
16
13
12
1
2
0
3
13,526
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.ProdLayer
class ProdLayer(Module): """Merge a shortcut with the result of the module by multiplying them.""" def forward(self, x): return x * x.orig
class ProdLayer(Module): '''Merge a shortcut with the result of the module by multiplying them.''' def forward(self, x): pass
2
1
1
0
1
0
1
0.5
1
0
0
0
1
0
1
13
3
0
2
2
1
1
3
2
1
1
2
0
1
13,527
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.ResBlock
class ResBlock(Module): """Resnet block from `ni` to `nh` with `stride`""" @delegates(ConvLayer.__init__) def __init__(self, expansion, ni, nf, stride=1, groups=1, reduction=None, nh1=None, nh2=None, dw=False, g2=1, sa=False, sym=False, norm_type=NormType.Batch, act_cls=defaults.activation, ndim=2, ks=3, p...
class ResBlock(Module): '''Resnet block from `ni` to `nh` with `stride`''' @delegates(ConvLayer.__init__) def __init__(self, expansion, ni, nf, stride=1, groups=1, reduction=None, nh1=None, nh2=None, dw=False, g2=1, sa=False, sym=False, norm_type=NormType.Batch, act_cls=defaults.activation, ndim=2, ks=3, po...
4
1
13
0
13
0
7
0.04
1
3
2
0
2
3
2
14
29
1
27
14
22
1
25
11
22
13
2
1
14
13,528
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.ResizeBatch
class ResizeBatch(Module): """Reshape `x` to `size`, keeping batch dim the same size""" def __init__(self, *size): self.size = size def forward(self, x): return x.view((x.size(0),) + self.size)
class ResizeBatch(Module): '''Reshape `x` to `size`, keeping batch dim the same size''' def __init__(self, *size): pass def forward(self, x): pass
3
1
1
0
1
0
1
0.33
1
0
0
0
2
1
2
14
4
0
3
3
2
1
5
4
2
1
2
0
2
13,529
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.SelfAttention
class SelfAttention(Module): """Self attention layer for `n_channels`.""" def __init__(self, n_channels): self.query, self.key, self.value = [self._conv(n_channels, c) for c in (n_channels // 8, n_channels // 8, n_channels)] self.gamma = nn.Parameter(tensor([0.0])) def _conv(self, n_in, n_...
class SelfAttention(Module): '''Self attention layer for `n_channels`.''' def __init__(self, n_channels): pass def _conv(self, n_in, n_out): pass def forward(self, x): pass
4
1
4
0
4
0
1
0.15
1
1
1
0
3
4
3
15
17
2
13
9
9
2
13
9
9
1
2
0
3
13,530
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.SequentialEx
class SequentialEx(Module): """Like `nn.Sequential`, but with ModuleList semantics, and can access module input""" def __init__(self, *layers): self.layers = nn.ModuleList(layers) def forward(self, x): res = x for l in self.layers: res.orig = x nres = l(res)...
class SequentialEx(Module): '''Like `nn.Sequential`, but with ModuleList semantics, and can access module input''' def __init__(self, *layers): pass def forward(self, x): pass def __getitem__(self, i): pass def append(self, l): pass def extend(self, l): ...
7
1
2
0
2
0
1
0.14
1
0
0
1
6
1
6
18
18
2
14
10
12
2
19
11
12
2
2
1
7
13,531
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.SimpleCNN
class SimpleCNN(nn.Sequential): """Create a simple CNN with `filters`.""" def __init__(self, filters, kernel_szs=None, strides=None, bn=True): nl = len(filters) - 1 kernel_szs = ifnone(kernel_szs, [3] * nl) strides = ifnone(strides, [2] * nl) layers = [ConvLayer(filters[i], filt...
class SimpleCNN(nn.Sequential): '''Create a simple CNN with `filters`.''' def __init__(self, filters, kernel_szs=None, strides=None, bn=True): pass
2
1
8
0
8
0
2
0.11
1
4
2
0
1
0
1
1
10
0
9
4
7
1
8
4
6
2
1
0
2
13,532
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.SimpleSelfAttention
class SimpleSelfAttention(Module): def __init__(self, n_in: int, ks=1, sym=False): self.sym, self.n_in = (sym, n_in) self.conv = _conv1d_spect(n_in, n_in, ks, padding=ks // 2, bias=False) self.gamma = nn.Parameter(tensor([0.0])) def forward(self, x): if self.sym: c ...
class SimpleSelfAttention(Module): def __init__(self, n_in: int, ks=1, sym=False): pass def forward(self, x): pass
3
0
9
1
8
0
2
0
1
1
0
0
2
4
2
14
20
3
17
10
14
0
17
10
14
2
2
1
3
13,533
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.SwishJit
class SwishJit(Module): def forward(self, x): return _SwishJitAutoFn.apply(x)
class SwishJit(Module): def forward(self, x): pass
2
0
1
0
1
0
1
0
1
1
1
0
1
0
1
13
2
0
2
2
1
0
3
2
1
1
2
0
1
13,534
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.TimeDistributed
class TimeDistributed(Module): """Applies `module` over `tdim` identically for each step, use `low_mem` to compute one at a time.""" def __init__(self, module, low_mem=False, tdim=1): store_attr() def forward(self, *tensors, **kwargs): """input x with shape:(bs,seq_len,channels,width,heigh...
class TimeDistributed(Module): '''Applies `module` over `tdim` identically for each step, use `low_mem` to compute one at a time.''' def __init__(self, module, low_mem=False, tdim=1): pass def forward(self, *tensors, **kwargs): '''input x with shape:(bs,seq_len,channels,width,height)''' ...
6
4
6
0
5
1
2
0.19
1
2
0
0
5
0
5
17
35
4
26
13
20
5
25
13
19
3
2
1
9
13,535
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers.View
class View(Module): """Reshape `x` to `size`""" def __init__(self, *size): self.size = size def forward(self, x): return x.view(self.size)
class View(Module): '''Reshape `x` to `size`''' def __init__(self, *size): pass def forward(self, x): pass
3
1
1
0
1
0
1
0.33
1
0
0
0
2
1
2
14
4
0
3
3
2
1
5
4
2
1
2
0
2
13,536
fastai/fastai
fastai_fastai/fastai/layers.py
fastai.layers._SwishJitAutoFn
class _SwishJitAutoFn(torch.autograd.Function): @staticmethod def forward(ctx, x): ctx.save_for_backward(x) return _swish_jit_fwd(x) @staticmethod def backward(ctx, grad_output): x = ctx.saved_variables[0] return _swish_jit_bwd(x, grad_output)
class _SwishJitAutoFn(torch.autograd.Function): @staticmethod def forward(ctx, x): pass @staticmethod def backward(ctx, grad_output): pass
5
0
3
0
3
0
1
0
1
0
0
0
0
0
2
2
10
1
9
6
4
0
7
4
4
1
1
0
2
13,537
fastai/fastai
fastai_fastai/fastai/learner.py
fastai.learner.AvgLoss
class AvgLoss(Metric): """Average the losses taking into account potential different batch sizes""" def reset(self): self.total, self.count = (0.0, 0) def accumulate(self, learn): bs = find_bs(learn.yb) self.total += learn.to_detach(learn.loss.mean()) * bs self.count += bs ...
class AvgLoss(Metric): '''Average the losses taking into account potential different batch sizes''' def reset(self): pass def accumulate(self, learn): pass @property def value(self): pass @property def name(self): pass
7
1
2
0
2
0
1
0.1
1
0
0
1
4
2
4
8
11
0
10
8
6
1
11
7
6
2
1
0
5
13,538
fastai/fastai
fastai_fastai/fastai/learner.py
fastai.learner.AvgMetric
class AvgMetric(Metric): """Average the values of `func` taking into account potential different batch sizes""" def __init__(self, func): self.func = func def reset(self): self.total, self.count = (0.0, 0) def accumulate(self, learn): bs = find_bs(learn.yb) self.total ...
class AvgMetric(Metric): '''Average the values of `func` taking into account potential different batch sizes''' def __init__(self, func): pass def reset(self): pass def accumulate(self, learn): pass @property def value(self): pass @property def name(sel...
8
1
2
0
2
0
1
0.09
1
0
0
1
5
3
5
9
12
0
11
9
7
1
13
9
7
2
1
0
7
13,539
fastai/fastai
fastai_fastai/fastai/learner.py
fastai.learner.AvgSmoothLoss
class AvgSmoothLoss(Metric): """Smooth average of the losses (exponentially weighted with `beta`)""" def __init__(self, beta=0.98): self.beta = beta def reset(self): self.count, self.val = (0, tensor(0.0)) def accumulate(self, learn): self.count += 1 self.val = torch.l...
class AvgSmoothLoss(Metric): '''Smooth average of the losses (exponentially weighted with `beta`)''' def __init__(self, beta=0.98): pass def reset(self): pass def accumulate(self, learn): pass @property def value(self): pass
6
1
2
0
2
0
1
0.13
1
0
0
0
4
3
4
8
9
0
8
6
5
1
10
7
5
1
1
0
4
13,540
fastai/fastai
fastai_fastai/fastai/learner.py
fastai.learner.CastToTensor
class CastToTensor(Callback): """Cast Subclassed Tensors to `Tensor`""" order = 9 def before_batch(self): self.learn.xb, self.learn.yb = (_cast_tensor(self.learn.xb), _cast_tensor(self.learn.yb))
class CastToTensor(Callback): '''Cast Subclassed Tensors to `Tensor`''' def before_batch(self): pass
2
1
2
0
2
0
1
0.5
1
0
0
0
1
0
1
6
6
1
4
3
2
2
4
3
2
1
2
0
1
13,541
fastai/fastai
fastai_fastai/fastai/learner.py
fastai.learner.Learner
from collections.abc import MutableSequence import threading class Learner(GetAttr): _default = 'model' def __init__(self, dls: DataLoaders, model: Callable, loss_func: Callable | None=None, opt_func: Optimizer | OptimWrapper=Adam, lr: float | slice=defaults.lr, splitter: Callable=trainable_params, cbs: Callb...
class Learner(GetAttr): def __init__(self, dls: DataLoaders, model: Callable, loss_func: Callable | None=None, opt_func: Optimizer | OptimWrapper=Adam, lr: float | slice=defaults.lr, splitter: Callable=trainable_params, cbs: Callback | MutableSequence | None=None, metrics: Callable | MutableSequence | None=None, ...
53
0
5
0
5
1
2
0.11
1
23
8
2
44
21
44
44
262
36
226
119
160
24
243
83
198
12
1
3
95
13,542
fastai/fastai
fastai_fastai/fastai/learner.py
fastai.learner.Metric
@docs class Metric: """Blueprint for defining a metric""" def reset(self): pass def accumulate(self, learn): pass @property def value(self): raise NotImplementedError @property def name(self): return class2attr(self, 'Metric') _docs = dict(reset='Reset...
@docs class Metric: '''Blueprint for defining a metric''' def reset(self): pass def accumulate(self, learn): pass @property def value(self): pass @property def name(self): pass
8
1
1
0
1
0
1
0.08
0
1
0
8
4
0
4
4
15
2
12
8
9
1
10
6
5
1
0
0
4
13,543
fastai/fastai
fastai_fastai/fastai/learner.py
fastai.learner.Recorder
from fastprogress.fastprogress import format_time class Recorder(Callback): """Callback that registers statistics (lr, loss and metrics) during training""" _stateattrs = ('lrs', 'iters', 'losses', 'values') remove_on_fetch, order = (True, 50) def __init__(self, add_time=True, train_metrics=False, vali...
class Recorder(Callback): '''Callback that registers statistics (lr, loss and metrics) during training''' def __init__(self, add_time=True, train_metrics=False, valid_metrics=True, beta=0.98): pass def before_fit(self): '''Prepare state for training''' pass def after_batch(se...
17
5
5
0
5
0
2
0.07
1
4
2
0
14
13
14
19
82
9
68
32
57
5
79
29
64
6
2
2
32
13,544
fastai/fastai
fastai_fastai/fastai/learner.py
fastai.learner.SkipToEpoch
class SkipToEpoch(Callback): """Skip training up to `epoch`""" order = 70 def __init__(self, epoch: int): self._skip_to = epoch def before_epoch(self): if self.epoch < self._skip_to: raise CancelEpochException
class SkipToEpoch(Callback): '''Skip training up to `epoch`''' def __init__(self, epoch: int): pass def before_epoch(self): pass
3
1
3
0
3
0
2
0.14
1
1
0
0
2
1
2
7
10
2
7
5
4
1
7
5
4
2
2
1
3
13,545
fastai/fastai
fastai_fastai/fastai/learner.py
fastai.learner.ValueMetric
class ValueMetric(Metric): """Use to include a pre-calculated metric value (for instance calculated in a `Callback`) and returned by `func`""" def __init__(self, func, metric_name=None): store_attr('func, metric_name') @property def value(self): return self.func() @property de...
class ValueMetric(Metric): '''Use to include a pre-calculated metric value (for instance calculated in a `Callback`) and returned by `func`''' def __init__(self, func, metric_name=None): pass @property def value(self): pass @property def name(self): pass
6
1
1
0
1
0
1
0.17
1
0
0
0
3
0
3
7
9
2
6
6
3
1
7
4
3
2
1
0
4
13,546
fastai/fastai
fastai_fastai/fastai/learner.py
fastai.learner._ConstantFunc
class _ConstantFunc: """Returns a function that returns `o`""" def __init__(self, o): self.o = o def __call__(self, *args, **kwargs): return self.o
class _ConstantFunc: '''Returns a function that returns `o`''' def __init__(self, o): pass def __call__(self, *args, **kwargs): pass
3
1
1
0
1
0
1
0.33
0
0
0
0
2
1
2
2
4
0
3
3
2
1
5
4
2
1
0
0
2
13,547
fastai/fastai
fastai_fastai/fastai/losses.py
fastai.losses.BCEWithLogitsLossFlat
@delegates() class BCEWithLogitsLossFlat(BaseLoss): """Same as `nn.BCEWithLogitsLoss`, but flattens input and target.""" @use_kwargs_dict(keep=True, weight=None, reduction='mean', pos_weight=None) def __init__(self, *args, axis: int=-1, floatify: bool=True, thresh: float=0.5, **kwargs): if kwargs.g...
@delegates() class BCEWithLogitsLossFlat(BaseLoss): '''Same as `nn.BCEWithLogitsLoss`, but flattens input and target.''' @use_kwargs_dict(keep=True, weight=None, reduction='mean', pos_weight=None) def __init__(self, *args, axis: int=-1, floatify: bool=True, thresh: float=0.5, **kwargs): pass de...
6
3
6
0
5
2
2
0.33
1
5
0
0
3
1
3
10
23
2
18
12
7
6
12
5
8
3
1
1
5
13,548
fastai/fastai
fastai_fastai/fastai/losses.py
fastai.losses.BaseLoss
class BaseLoss: """Same as `loss_cls`, but flattens input and target.""" activation = decodes = noops def __init__(self, loss_cls, *args, axis: int=-1, flatten: bool=True, floatify: bool=False, is_2d: bool=True, **kwargs): store_attr('axis,flatten,floatify,is_2d') self.func = loss_cls(*args...
class BaseLoss: '''Same as `loss_cls`, but flattens input and target.''' def __init__(self, loss_cls, *args, axis: int=-1, flatten: bool=True, floatify: bool=False, is_2d: bool=True, **kwargs): pass def __repr__(self) -> str: pass @property def reduction(self) -> str: pass ...
10
4
5
0
4
2
2
0.37
0
7
1
4
7
2
7
7
45
6
35
25
15
13
27
10
19
6
0
1
14
13,549
fastai/fastai
fastai_fastai/fastai/losses.py
fastai.losses.CrossEntropyLossFlat
@delegates() class CrossEntropyLossFlat(BaseLoss): """Same as `nn.CrossEntropyLoss`, but flattens input and target.""" y_int = True @use_kwargs_dict(keep=True, weight=None, ignore_index=-100, reduction='mean') def __init__(self, *args, axis: int=-1, **kwargs): super().__init__(nn.CrossEntropyLo...
@delegates() class CrossEntropyLossFlat(BaseLoss): '''Same as `nn.CrossEntropyLoss`, but flattens input and target.''' @use_kwargs_dict(keep=True, weight=None, ignore_index=-100, reduction='mean') def __init__(self, *args, axis: int=-1, **kwargs): pass def decodes(self, x: Tensor) -> Tensor: ...
6
3
4
0
3
1
1
0.38
1
2
0
0
3
0
3
10
18
2
13
10
4
5
8
5
4
1
1
0
3
13,550
fastai/fastai
fastai_fastai/fastai/losses.py
fastai.losses.DiceLoss
class DiceLoss: """Dice loss for segmentation""" def __init__(self, axis: int=1, smooth: float=1e-06, reduction: str='sum', square_in_union: bool=False): store_attr() def __call__(self, pred: Tensor, targ: Tensor) -> Tensor: """One-hot encodes targ, then runs IoU calculation then takes 1-d...
class DiceLoss: '''Dice loss for segmentation''' def __init__(self, axis: int=1, smooth: float=1e-06, reduction: str='sum', square_in_union: bool=False): pass def __call__(self, pred: Tensor, targ: Tensor) -> Tensor: '''One-hot encodes targ, then runs IoU calculation then takes 1-dice valu...
7
5
7
0
7
2
2
0.34
0
7
1
0
4
0
5
5
43
3
35
21
19
12
23
11
17
4
0
1
8
13,551
fastai/fastai
fastai_fastai/fastai/losses.py
fastai.losses.FocalLoss
class FocalLoss(Module): y_int = True def __init__(self, gamma: float=2.0, weight: Tensor=None, reduction: str='mean'): """Applies Focal Loss: https://arxiv.org/pdf/1708.02002.pdf""" store_attr() def forward(self, inp: Tensor, targ: Tensor) -> Tensor: """Applies focal loss based on...
class FocalLoss(Module): def __init__(self, gamma: float=2.0, weight: Tensor=None, reduction: str='mean'): '''Applies Focal Loss: https://arxiv.org/pdf/1708.02002.pdf''' pass def forward(self, inp: Tensor, targ: Tensor) -> Tensor: '''Applies focal loss based on https://arxiv.org/pdf/17...
3
2
9
0
8
3
2
0.35
1
2
0
0
2
1
2
14
20
1
17
11
10
6
12
7
9
3
2
1
4
13,552
fastai/fastai
fastai_fastai/fastai/losses.py
fastai.losses.FocalLossFlat
class FocalLossFlat(BaseLoss): """ Same as CrossEntropyLossFlat but with focal paramter, `gamma`. Focal loss is introduced by Lin et al. https://arxiv.org/pdf/1708.02002.pdf. Note the class weighting factor in the paper, alpha, can be implemented through pytorch `weight` argument passed through to F.c...
class FocalLossFlat(BaseLoss): ''' Same as CrossEntropyLossFlat but with focal paramter, `gamma`. Focal loss is introduced by Lin et al. https://arxiv.org/pdf/1708.02002.pdf. Note the class weighting factor in the paper, alpha, can be implemented through pytorch `weight` argument passed through to F.c...
5
3
4
0
4
1
1
0.71
1
4
1
0
3
0
3
10
23
2
14
11
4
10
8
5
4
1
1
0
3
13,553
fastai/fastai
fastai_fastai/fastai/losses.py
fastai.losses.LabelSmoothingCrossEntropy
class LabelSmoothingCrossEntropy(Module): y_int = True def __init__(self, eps: float=0.1, weight: Tensor=None, reduction: str='mean'): store_attr() def forward(self, output: Tensor, target: Tensor) -> Tensor: """Apply `F.log_softmax` on output then blend the loss/num_classes(`c`) with the ...
class LabelSmoothingCrossEntropy(Module): def __init__(self, eps: float=0.1, weight: Tensor=None, reduction: str='mean'): pass def forward(self, output: Tensor, target: Tensor) -> Tensor: '''Apply `F.log_softmax` on output then blend the loss/num_classes(`c`) with the `F.nll_loss`''' p...
5
3
5
0
5
2
2
0.4
1
2
0
0
4
2
4
16
26
3
20
14
11
8
17
9
12
3
2
2
6
13,554
fastai/fastai
fastai_fastai/fastai/losses.py
fastai.losses.LabelSmoothingCrossEntropyFlat
@delegates() class LabelSmoothingCrossEntropyFlat(BaseLoss): """Same as `LabelSmoothingCrossEntropy`, but flattens input and target.""" y_int = True @use_kwargs_dict(keep=True, eps=0.1, reduction='mean') def __init__(self, *args, axis: int=-1, **kwargs): super().__init__(LabelSmoothingCrossEntr...
@delegates() class LabelSmoothingCrossEntropyFlat(BaseLoss): '''Same as `LabelSmoothingCrossEntropy`, but flattens input and target.''' @use_kwargs_dict(keep=True, eps=0.1, reduction='mean') def __init__(self, *args, axis: int=-1, **kwargs): pass def activation(self, out: Tensor) -> Tensor: ...
6
3
4
0
3
1
1
0.31
1
3
1
0
3
0
3
10
17
1
13
10
4
4
8
5
4
1
1
0
3
13,555
fastai/fastai
fastai_fastai/fastai/medical/imaging.py
fastai.medical.imaging.DicomSegmentationDataLoaders
class DicomSegmentationDataLoaders(DataLoaders): """Basic wrapper around DICOM `DataLoaders` 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_...
class DicomSegmentationDataLoaders(DataLoaders): '''Basic wrapper around DICOM `DataLoaders` 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_t...
4
2
9
0
8
1
1
0.18
1
2
2
0
0
0
1
15
13
0
11
5
7
2
5
4
3
1
2
0
1
13,556
fastai/fastai
fastai_fastai/fastai/medical/imaging.py
fastai.medical.imaging.PILCTScan
class PILCTScan(PILBase): _open_args, _tensor_cls, _show_args = ({}, TensorCTScan, TensorCTScan._show_args)
class PILCTScan(PILBase): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
3
1
0
1
1
1
0
2
2
1
0
2
0
0
13,557
fastai/fastai
fastai_fastai/fastai/medical/imaging.py
fastai.medical.imaging.PILDicom
from PIL import Image import pydicom class PILDicom(PILBase): _open_args, _tensor_cls, _show_args = ({}, TensorDicom, TensorDicom._show_args) @classmethod def create(cls, fn: Path | str | bytes, mode=None) -> None: """Open a `DICOM file` from path `fn` or bytes `fn` and load it as a `PIL Image`"""...
class PILDicom(PILBase): @classmethod def create(cls, fn: Path | str | bytes, mode=None) -> None: '''Open a `DICOM file` from path `fn` or bytes `fn` and load it as a `PIL Image`''' pass
3
1
7
0
6
1
4
0.11
1
3
0
0
0
0
1
4
10
0
9
5
6
1
10
4
8
4
2
1
4
13,558
fastai/fastai
fastai_fastai/fastai/medical/imaging.py
fastai.medical.imaging.TensorCTScan
class TensorCTScan(TensorImageBW): """Inherits from `TensorImageBW` and converts the `pixel_array` into a `TensorCTScan`""" _show_args = {'cmap': 'bone'}
class TensorCTScan(TensorImageBW): '''Inherits from `TensorImageBW` and converts the `pixel_array` into a `TensorCTScan`''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
14
3
0
2
2
1
1
2
2
1
0
5
0
0
13,559
fastai/fastai
fastai_fastai/fastai/medical/imaging.py
fastai.medical.imaging.TensorDicom
class TensorDicom(TensorImage): """Inherits from `TensorImage` and converts the `pixel_array` into a `TensorDicom`""" _show_args = {'cmap': 'gray'}
class TensorDicom(TensorImage): '''Inherits from `TensorImage` and converts the `pixel_array` into a `TensorDicom`''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
14
3
0
2
2
1
1
2
2
1
0
4
0
0
13,560
fastai/fastai
fastai_fastai/fastai/metrics.py
fastai.metrics.AccumMetric
class AccumMetric(Metric): """Stores predictions and targets on CPU in accumulate to perform final calculations with `func`.""" def __init__(self, func, dim_argmax=None, activation=ActivationType.No, thresh=None, to_np=False, invert_arg=False, flatten=True, name=None, **kwargs): store_attr('func,dim_ar...
class AccumMetric(Metric): '''Stores predictions and targets on CPU in accumulate to perform final calculations with `func`.''' def __init__(self, func, dim_argmax=None, activation=ActivationType.No, thresh=None, to_np=False, invert_arg=False, flatten=True, name=None, **kwargs): pass def reset(sel...
12
6
5
0
4
1
2
0.16
1
0
0
0
8
10
8
12
50
7
37
23
26
6
40
15
31
6
1
2
19
13,561
fastai/fastai
fastai_fastai/fastai/metrics.py
fastai.metrics.CorpusBLEUMetric
class CorpusBLEUMetric(Metric): def __init__(self, vocab_sz=5000, axis=-1): """BLEU Metric calculated over the validation corpus""" self.metric_name = 'CorpusBLEU' self.axis, self.vocab_sz = (axis, vocab_sz) self.pred_len, self.targ_len, self.samp_idx, self.corrects, self.counts = (...
class CorpusBLEUMetric(Metric): def __init__(self, vocab_sz=5000, axis=-1): '''BLEU Metric calculated over the validation corpus''' pass def reset(self): pass class NGram: def __init__(self, vocab_sz=5000, axis=-1): pass def __eq__(self, other): ...
12
1
5
0
4
0
2
0.05
1
4
1
0
6
8
6
10
50
6
43
26
33
2
45
25
34
5
1
4
18
13,562
fastai/fastai
fastai_fastai/fastai/metrics.py
fastai.metrics.Dice
class Dice(Metric): """Dice coefficient metric for binary target in segmentation""" def __init__(self, axis=1): self.axis = axis def reset(self): self.inter, self.union = (0, 0) def accumulate(self, learn): pred, targ = flatten_check(learn.pred.argmax(dim=self.axis), learn.y) ...
class Dice(Metric): '''Dice coefficient metric for binary target in segmentation''' def __init__(self, axis=1): pass def reset(self): pass def accumulate(self, learn): pass @property def value(self): pass
6
1
2
0
2
0
1
0.11
1
0
0
1
4
3
4
8
11
1
9
7
6
1
11
8
6
2
1
0
5
13,563
fastai/fastai
fastai_fastai/fastai/metrics.py
fastai.metrics.DiceMulti
class DiceMulti(Metric): """Averaged Dice metric (Macro F1) for multiclass target in segmentation""" def __init__(self, axis=1): self.axis = axis def reset(self): self.inter, self.union = ({}, {}) def accumulate(self, learn): pred, targ = flatten_check(learn.pred.argmax(dim=se...
class DiceMulti(Metric): '''Averaged Dice metric (Macro F1) for multiclass target in segmentation''' def __init__(self, axis=1): pass def reset(self): pass def accumulate(self, learn): pass @property def value(self): pass
6
1
5
0
5
0
2
0.05
1
1
0
1
4
3
4
8
24
1
22
14
18
1
22
15
17
3
1
2
8
13,564
fastai/fastai
fastai_fastai/fastai/metrics.py
fastai.metrics.JaccardCoeff
class JaccardCoeff(Dice): """Implementation of the Jaccard coefficient that is lighter in RAM""" @property def value(self): return self.inter / (self.union - self.inter) if self.union > 0 else None
class JaccardCoeff(Dice): '''Implementation of the Jaccard coefficient that is lighter in RAM''' @property def value(self): pass
3
1
1
0
1
0
2
0.33
1
0
0
0
1
0
1
9
4
0
3
3
1
1
3
2
1
2
2
0
2
13,565
fastai/fastai
fastai_fastai/fastai/metrics.py
fastai.metrics.JaccardCoeffMulti
class JaccardCoeffMulti(DiceMulti): """Averaged Jaccard coefficient metric (mIoU) for multiclass target in segmentation""" @property def value(self): binary_jaccard_scores = np.array([]) for c in self.inter: binary_jaccard_scores = np.append(binary_jaccard_scores, self.inter[c] ...
class JaccardCoeffMulti(DiceMulti): '''Averaged Jaccard coefficient metric (mIoU) for multiclass target in segmentation''' @property def value(self): pass
3
1
5
0
5
0
3
0.14
1
0
0
0
1
0
1
9
8
0
7
5
4
1
6
4
4
3
2
1
3
13,566
fastai/fastai
fastai_fastai/fastai/metrics.py
fastai.metrics.LossMetric
class LossMetric(AvgMetric): """Create a metric from `loss_func.attr` named `nm`""" def __init__(self, attr, nm=None): store_attr('attr,nm') def accumulate(self, learn): bs = find_bs(learn.yb) self.total += learn.to_detach(getattr(learn.loss_func, self.attr, 0)) * bs self.c...
class LossMetric(AvgMetric): '''Create a metric from `loss_func.attr` named `nm`''' def __init__(self, attr, nm=None): pass def accumulate(self, learn): pass @property def name(self): pass
5
1
2
0
2
0
1
0.13
1
0
0
0
3
0
3
12
10
1
8
6
5
1
9
5
5
2
2
0
4
13,567
fastai/fastai
fastai_fastai/fastai/metrics.py
fastai.metrics.Perplexity
class Perplexity(AvgLoss): """Perplexity (exponential of cross-entropy loss) for Language Models""" @property def value(self): return torch.exp(self.total / self.count) if self.count != 0 else None @property def name(self): return 'perplexity'
class Perplexity(AvgLoss): '''Perplexity (exponential of cross-entropy loss) for Language Models''' @property def value(self): pass @property def name(self): pass
5
1
1
0
1
0
2
0.2
1
0
0
0
2
0
2
10
6
0
5
5
2
1
5
3
2
2
2
0
3
13,568
fastai/fastai
fastai_fastai/fastai/optimizer.py
fastai.optimizer.Lookahead
class Lookahead(Optimizer, GetAttr): """Wrap `opt` in a lookahead optimizer""" _default = 'opt' def __init__(self, opt: Optimizer, k: int=6, alpha: float=0.5): store_attr('opt,k,alpha') self._init_state() def step(self, closure=None): if closure is not None: raise N...
class Lookahead(Optimizer, GetAttr): '''Wrap `opt` in a lookahead optimizer''' def __init__(self, opt: Optimizer, k: int=6, alpha: float=0.5): pass def step(self, closure=None): pass def clear_state(self): pass def state_dict(self): pass def load_state_dict(s...
12
1
4
0
4
0
2
0.11
2
4
0
0
9
2
9
25
43
6
36
22
24
4
37
16
27
6
2
2
14
13,569
fastai/fastai
fastai_fastai/fastai/optimizer.py
fastai.optimizer.OptimWrapper
class OptimWrapper(_BaseOptimizer, GetAttr): """A wrapper class for existing PyTorch optimizers""" _xtra = ['zero_grad', 'step', 'state_dict', 'load_state_dict'] _default = 'opt' def __init__(self, params: Tensor | Iterable=None, opt: Callable | torch.optim.Optimizer=None, hp_map: dict=None, convert_gr...
class OptimWrapper(_BaseOptimizer, GetAttr): '''A wrapper class for existing PyTorch optimizers''' def __init__(self, params: Tensor | Iterable=None, opt: Callable | torch.optim.Optimizer=None, hp_map: dict=None, convert_groups: bool=True, **kwargs): pass @property def hypers(self): pas...
10
1
5
0
5
1
3
0.14
2
6
0
0
6
5
6
16
40
4
35
25
21
5
32
16
25
8
1
2
15
13,570
fastai/fastai
fastai_fastai/fastai/optimizer.py
fastai.optimizer.Optimizer
class Optimizer(_BaseOptimizer): """Base optimizer class for the fastai library, updating `params` with `cbs`""" _keep_on_clear = ['force_train', 'do_wd'] def __init__(self, params: Tensor | Iterable, cbs: Callable | MutableSequence, **defaults): if 'train_bn' in defaults.keys(): _ = de...
class Optimizer(_BaseOptimizer): '''Base optimizer class for the fastai library, updating `params` with `cbs`''' def __init__(self, params: Tensor | Iterable, cbs: Callable | MutableSequence, **defaults): pass def zero_grad(self): pass def step(self, closure=None): pass d...
7
1
6
0
6
1
2
0.13
1
6
0
1
6
5
6
16
45
5
39
24
26
5
35
18
28
4
1
2
13
13,571
fastai/fastai
fastai_fastai/fastai/optimizer.py
fastai.optimizer._BaseOptimizer
class _BaseOptimizer: """Common functionality between `Optimizer` and `OptimWrapper`""" def all_params(self, n: slice | int=slice(None), with_grad: bool=False): res = L(((p, pg, self.state[p], hyper) for pg, hyper in zip(self.param_lists[n], self.hypers[n]) for p in pg)) return L((o for o in re...
class _BaseOptimizer: '''Common functionality between `Optimizer` and `OptimWrapper`''' def all_params(self, n: slice | int=slice(None), with_grad: pass def _set_require_grad(self, rg: bool, p: Tensor, pg, state: dict, h): pass def freeze_to(self, n: int): pass def freeze...
13
1
5
0
5
1
2
0.24
0
5
0
2
10
3
10
10
59
4
54
40
25
13
43
18
32
5
0
3
23
13,572
fastai/fastai
fastai_fastai/fastai/tabular/core.py
fastai.tabular.core.Categorify
class Categorify(TabularProc): """Transform the categorical variables to something similar to `pd.Categorical`""" order = 1 def setups(self, to): store_attr(classes={n: CategoryMap(to.iloc[:, n].items, add_na=n in to.cat_names) for n in to.cat_names}, but='to') def encodes(self, to): t...
class Categorify(TabularProc): '''Transform the categorical variables to something similar to `pd.Categorical`''' def setups(self, to): pass def encodes(self, to): pass def decodes(self, to): pass def __getitem__(self, k): pass
5
1
1
0
1
0
1
0.14
1
2
1
0
4
0
4
6
9
1
7
6
5
1
10
6
5
1
2
0
4
13,573
fastai/fastai
fastai_fastai/fastai/tabular/core.py
fastai.tabular.core.FillMissing
class FillMissing(TabularProc): """Fill the missing values in continuous columns.""" def __init__(self, fill_strategy=FillStrategy.median, add_col=True, fill_vals=None): if fill_vals is None: fill_vals = defaultdict(int) store_attr() def setups(self, to): missing = pd.i...
class FillMissing(TabularProc): '''Fill the missing values in continuous columns.''' def __init__(self, fill_strategy=FillStrategy.median, add_col=True, fill_vals=None): pass def setups(self, to): pass def encodes(self, to): pass
4
1
6
0
6
0
3
0.06
1
2
1
0
3
1
3
5
21
2
18
8
14
1
19
8
15
5
2
3
8
13,574
fastai/fastai
fastai_fastai/fastai/tabular/core.py
fastai.tabular.core.FillStrategy
class FillStrategy: """Namespace containing the various filling strategies.""" def median(c, fill): return c.median() def constant(c, fill): return fill def mode(c, fill): return c.dropna().value_counts().idxmax()
class FillStrategy: '''Namespace containing the various filling strategies.''' def median(c, fill): pass def constant(c, fill): pass def mode(c, fill): pass
4
1
1
0
1
0
1
0.25
0
0
0
0
3
0
3
3
5
0
4
4
3
1
7
4
3
1
0
0
3
13,575
fastai/fastai
fastai_fastai/fastai/tabular/core.py
fastai.tabular.core.ReadTabBatch
class ReadTabBatch(ItemTransform): """Transform `TabularPandas` values into a `Tensor` with the ability to decode""" def __init__(self, to): self.to = to.new_empty() def encodes(self, to): if not to.with_cont: res = (tensor(to.cats).long(),) else: res = (ten...
class ReadTabBatch(ItemTransform): '''Transform `TabularPandas` values into a `Tensor` with the ability to decode''' def __init__(self, to): pass def encodes(self, to): pass def decodes(self, o): pass
4
1
5
0
5
0
2
0.06
1
0
0
0
3
1
3
3
19
2
16
9
13
1
22
10
18
4
1
1
7
13,576
fastai/fastai
fastai_fastai/fastai/tabular/core.py
fastai.tabular.core.TabDataLoader
@delegates() class TabDataLoader(TfmdDL): """A transformed `DataLoader` for Tabular data""" def __init__(self, dataset, bs=16, shuffle=False, after_batch=None, num_workers=0, **kwargs): if after_batch is None: after_batch = L(TransformBlock().batch_tfms) + ReadTabBatch(dataset) supe...
@delegates() class TabDataLoader(TfmdDL): '''A transformed `DataLoader` for Tabular data''' def __init__(self, dataset, bs=16, shuffle=False, after_batch=None, num_workers=0, **kwargs): pass def create_item(self, s): pass def create_batch(self, b): pass def do_item(self, ...
6
1
2
0
2
0
2
0.14
1
3
2
1
4
0
4
36
9
1
7
5
5
1
11
5
6
2
3
1
6
13,577
fastai/fastai
fastai_fastai/fastai/tabular/core.py
fastai.tabular.core.TabWeightedDL
@delegates() class TabWeightedDL(TabDataLoader): """A transformed `DataLoader` for Tabular Weighted data""" def __init__(self, dataset, bs=16, wgts=None, shuffle=False, after_batch=None, num_workers=0, **kwargs): wgts = np.array([1.0] * len(dataset) if wgts is None else wgts) self.wgts = wgts /...
@delegates() class TabWeightedDL(TabDataLoader): '''A transformed `DataLoader` for Tabular Weighted data''' def __init__(self, dataset, bs=16, wgts=None, shuffle=False, after_batch=None, num_workers=0, **kwargs): pass def get_idxs(self): pass
4
1
5
0
5
0
3
0.1
1
2
0
0
2
3
2
38
12
1
10
6
7
1
12
5
9
3
4
1
5
13,578
fastai/fastai
fastai_fastai/fastai/tabular/core.py
fastai.tabular.core.Tabular
class Tabular(CollBase, GetAttr, FilteredBase): """A `DataFrame` wrapper that knows which cols are cont/cat/y, and returns rows in `__getitem__`""" _default, with_cont = ('procs', True) def __init__(self, df, procs=None, cat_names=None, cont_names=None, y_names=None, y_block=None, splits=None, do_setup=Tru...
class Tabular(CollBase, GetAttr, FilteredBase): '''A `DataFrame` wrapper that knows which cols are cont/cat/y, and returns rows in `__getitem__`''' def __init__(self, df, procs=None, cat_names=None, cont_names=None, y_names=None, y_block=None, splits=None, do_setup=True, device=None, inplace=False, reduce_memo...
19
1
3
0
2
0
2
0.04
3
5
2
1
18
8
18
23
51
4
45
27
39
2
64
27
45
11
1
2
30
13,579
fastai/fastai
fastai_fastai/fastai/tabular/core.py
fastai.tabular.core.TabularPandas
class TabularPandas(Tabular): """A `Tabular` object with transforms""" def transform(self, cols, f, all_col=True): if not all_col: cols = [c for c in cols if c in self.items.columns] if len(cols) > 0: self[cols] = self[cols].transform(f)
class TabularPandas(Tabular): '''A `Tabular` object with transforms''' def transform(self, cols, f, all_col=True): pass
2
1
3
0
3
0
3
0.25
1
0
0
1
1
0
1
24
5
0
4
2
2
1
6
2
4
3
2
1
3
13,580
fastai/fastai
fastai_fastai/fastai/tabular/core.py
fastai.tabular.core.TabularProc
class TabularProc(InplaceTransform): """Base class to write a non-lazy tabular processor for dataframes""" def setup(self, items=None, train_setup=False): super().setup(getattr(items, 'train', items), train_setup=False) return self(items.items if isinstance(items, Datasets) else items) @pr...
class TabularProc(InplaceTransform): '''Base class to write a non-lazy tabular processor for dataframes''' def setup(self, items=None, train_setup=False): pass @property def name(self): pass
4
1
3
0
2
1
2
0.5
1
2
1
2
2
0
2
2
9
1
6
4
3
3
6
3
3
2
1
0
3
13,581
fastai/fastai
fastai_fastai/fastai/tabular/core.py
fastai.tabular.core._TabIloc
class _TabIloc: """Get/set rows by iloc and cols by name""" def __init__(self, to): self.to = to def __getitem__(self, idxs): df = self.to.items if isinstance(idxs, tuple): rows, cols = idxs cols = df.columns.isin(cols) if is_listy(cols) else df.columns.get_...
class _TabIloc: '''Get/set rows by iloc and cols by name''' def __init__(self, to): pass def __getitem__(self, idxs): pass
3
1
4
0
4
0
2
0.11
0
2
0
0
2
1
2
2
10
0
9
5
7
1
10
6
7
3
0
1
4
13,582
fastai/fastai
fastai_fastai/fastai/tabular/data.py
fastai.tabular.data.TabularDataLoaders
class TabularDataLoaders(DataLoaders): """Basic wrapper around several `DataLoader`s with factory methods for tabular data""" @classmethod @delegates(Tabular.dataloaders, but=['dl_type', 'dl_kwargs']) def from_df(cls, df: pd.DataFrame, path: str | Path='.', procs: list=None, cat_names: list=None, cont_...
class TabularDataLoaders(DataLoaders): '''Basic wrapper around several `DataLoader`s with factory methods for tabular data''' @classmethod @delegates(Tabular.dataloaders, but=['dl_type', 'dl_kwargs']) def from_df(cls, df: pd.DataFrame, path: str | Path='.', procs: list=None, cat_names: list=None, cont_n...
8
4
12
0
11
5
2
0.46
1
7
2
0
1
0
3
17
43
2
37
30
9
17
16
7
12
4
2
1
7
13,583
fastai/fastai
fastai_fastai/fastai/tabular/learner.py
fastai.tabular.learner.TabularLearner
class TabularLearner(Learner): """`Learner` for tabular data""" def predict(self, row: pd.Series): """Predict on a single sample""" dl = self.dls.test_dl(row.to_frame().T) dl.dataset.conts = dl.dataset.conts.astype(np.float32) inp, preds, _, dec_preds = self.get_preds(dl=dl, wit...
class TabularLearner(Learner): '''`Learner` for tabular data''' def predict(self, row: pd.Series): '''Predict on a single sample''' pass
2
2
10
0
9
2
1
0.3
1
1
0
0
1
0
1
45
12
0
10
8
6
3
8
6
6
1
2
0
1
13,584
fastai/fastai
fastai_fastai/fastai/tabular/model.py
fastai.tabular.model.TabularModel
class TabularModel(Module): """Basic model for tabular data.""" def __init__(self, emb_szs: list, n_cont: int, out_sz: int, layers: list, ps: float | MutableSequence=None, embed_p: float=0.0, y_range=None, use_bn: bool=True, bn_final: bool=False, bn_cont: bool=True, act_cls=nn.ReLU(inplace=True), lin_first: bo...
class TabularModel(Module): '''Basic model for tabular data.''' def __init__(self, emb_szs: list, n_cont: int, out_sz: int, layers: list, ps: float | MutableSequence=None, embed_p: float=0.0, y_range=None, use_bn: bool=True, bn_final: bool=False, bn_cont: bool=True, act_cls=nn.ReLU(inplace=True), lin_first: ...
3
1
18
0
18
6
5
0.35
1
10
2
1
2
6
2
14
39
1
37
26
21
13
26
13
23
5
2
2
9
13,585
fastai/fastai
fastai_fastai/fastai/text/core.py
fastai.text.core.BaseTokenizer
class BaseTokenizer: """Basic tokenizer that just splits on spaces""" def __init__(self, split_char=' ', **kwargs): self.split_char = split_char def __call__(self, items): return (t.split(self.split_char) for t in items)
class BaseTokenizer: '''Basic tokenizer that just splits on spaces''' def __init__(self, split_char=' ', **kwargs): pass def __call__(self, items): pass
3
1
1
0
1
0
1
0.33
0
0
0
0
2
1
2
2
4
0
3
3
2
1
5
4
2
1
0
0
2
13,586
fastai/fastai
fastai_fastai/fastai/text/core.py
fastai.text.core.SentencePieceTokenizer
class SentencePieceTokenizer: """SentencePiece tokenizer for `lang`""" def __init__(self, lang='en', special_toks=None, sp_model=None, vocab_sz=None, max_vocab_sz=30000, model_type='unigram', char_coverage=None, cache_dir='tmp'): try: from sentencepiece import SentencePieceTrainer, Sentence...
class SentencePieceTokenizer: '''SentencePiece tokenizer for `lang`''' def __init__(self, lang='en', special_toks=None, sp_model=None, vocab_sz=None, max_vocab_sz=30000, model_type='unigram', char_coverage=None, cache_dir='tmp'): pass def _get_vocab_sz(self, raw_text_path): pass def t...
6
2
10
0
10
0
3
0.06
0
5
0
0
5
8
5
5
56
4
50
26
41
3
52
23
43
4
0
3
17
13,587
fastai/fastai
fastai_fastai/fastai/text/core.py
fastai.text.core.SpacyTokenizer
class SpacyTokenizer: """Spacy tokenizer for `lang`""" def __init__(self, lang='en', special_toks=None, buf_sz=5000): import spacy from spacy.symbols import ORTH self.special_toks = ifnone(special_toks, defaults.text_spec_tok) nlp = spacy.blank(lang) for w in self.specia...
class SpacyTokenizer: '''Spacy tokenizer for `lang`''' def __init__(self, lang='en', special_toks=None, buf_sz=5000): pass def __call__(self, items): pass
3
1
5
0
5
0
2
0.1
0
2
0
0
2
3
2
2
12
1
10
10
5
1
11
9
6
2
0
1
3
13,588
fastai/fastai
fastai_fastai/fastai/text/core.py
fastai.text.core.TokenizeWithRules
class TokenizeWithRules: """A wrapper around `tok` which applies `rules`, then tokenizes, then applies `post_rules`""" def __init__(self, tok, rules=None, post_rules=None): self.rules = L(ifnone(rules, defaults.text_proc_rules)) self.post_f = compose(*L(ifnone(post_rules, defaults.text_postproc...
class TokenizeWithRules: '''A wrapper around `tok` which applies `rules`, then tokenizes, then applies `post_rules`''' def __init__(self, tok, rules=None, post_rules=None): pass def __call__(self, batch): pass
3
1
3
0
3
0
1
0.14
0
0
0
0
2
3
2
2
9
1
7
7
4
1
7
6
4
1
0
0
2
13,589
fastai/fastai
fastai_fastai/fastai/text/core.py
fastai.text.core.Tokenizer
class Tokenizer(Transform): """Provides a consistent `Transform` interface to tokenizers operating on `DataFrame`s and folders""" input_types = (str, list, L, tuple, Path) def __init__(self, tok, rules=None, counter=None, lengths=None, mode=None, sep=' '): if isinstance(tok, type): tok ...
class Tokenizer(Transform): '''Provides a consistent `Transform` interface to tokenizers operating on `DataFrame`s and folders''' def __init__(self, tok, rules=None, counter=None, lengths=None, mode=None, sep=' '): pass @classmethod @delegates(tokenize_df, keep=True) def from_df(cls, text_c...
14
1
5
0
5
0
3
0.02
1
4
1
0
7
4
9
9
58
7
50
23
39
1
57
21
47
7
1
3
23
13,590
fastai/fastai
fastai_fastai/fastai/text/data.py
fastai.text.data.LMDataLoader
@delegates() class LMDataLoader(TfmdDL): """A `DataLoader` suitable for language modeling""" def __init__(self, dataset, lens=None, cache=2, bs=64, seq_len=72, num_workers=0, **kwargs): self.items = ReindexCollection(dataset, cache=cache, tfm=_maybe_first) self.seq_len = seq_len if lens...
@delegates() class LMDataLoader(TfmdDL): '''A `DataLoader` suitable for language modeling''' def __init__(self, dataset, lens=None, cache=2, bs=64, seq_len=72, num_workers=0, **kwargs): pass def make_chunks(self): pass def shuffle_fn(self, idxs): pass def create_item(self...
8
1
6
0
6
0
2
0.1
1
5
2
0
5
8
5
5
36
3
31
20
25
3
35
19
29
4
1
1
12
13,591
fastai/fastai
fastai_fastai/fastai/text/data.py
fastai.text.data.LMTensorText
class LMTensorText(TensorText): pass
class LMTensorText(TensorText): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
1
1
1
0
2
1
1
0
2
0
0
13,592
fastai/fastai
fastai_fastai/fastai/text/data.py
fastai.text.data.Numericalize
class Numericalize(Transform): """Reversible transform of tokenized texts to numericalized ids""" def __init__(self, vocab=None, min_freq=3, max_vocab=60000, special_toks=None): store_attr('vocab,min_freq,max_vocab,special_toks') self.o2i = None if vocab is None else defaultdict(int, {v: k for ...
class Numericalize(Transform): '''Reversible transform of tokenized texts to numericalized ids''' def __init__(self, vocab=None, min_freq=3, max_vocab=60000, special_toks=None): pass def setups(self, dsets): pass def encodes(self, o): pass def decodes(self, o): pa...
5
1
3
0
3
0
2
0.07
1
4
1
0
4
5
4
4
17
2
14
10
11
1
17
9
12
5
1
2
9
13,593
fastai/fastai
fastai_fastai/fastai/text/data.py
fastai.text.data.Pad_Chunk
class Pad_Chunk(DisplayedTransform): """Pad `samples` by adding padding by chunks of size `seq_len`""" def __init__(self, pad_idx=1, pad_first=True, seq_len=72, decode=True, **kwargs): store_attr('pad_idx, pad_first, seq_len,seq_len') super().__init__(**kwargs) def before_call(self, b): ...
class Pad_Chunk(DisplayedTransform): '''Pad `samples` by adding padding by chunks of size `seq_len`''' def __init__(self, pad_idx=1, pad_first=True, seq_len=72, decode=True, **kwargs): pass def before_call(self, b): '''Set `self.max_len` before encodes''' pass def __call__(sel...
6
2
3
0
2
0
1
0.15
1
3
1
0
5
4
5
5
15
0
13
8
7
2
13
7
7
2
1
0
6
13,594
fastai/fastai
fastai_fastai/fastai/text/data.py
fastai.text.data.Pad_Input
class Pad_Input(ItemTransform): def encodes(self, samples, pad_idx=1, pad_fields=0, pad_first=False, backwards=False): """Function that collect `samples` and adds padding""" self.pad_idx = pad_idx pad_fields = L(pad_fields) max_len_l = pad_fields.map(lambda f: max([len(s[f]) for s i...
class Pad_Input(ItemTransform): def encodes(self, samples, pad_idx=1, pad_fields=0, pad_first=False, backwards=False): '''Function that collect `samples` and adds padding''' pass def _f(field_idx, x): pass def decodes(self, o: TensorText): pass
4
1
9
0
8
1
3
0.11
1
5
1
0
2
1
2
2
19
0
18
11
14
2
21
11
17
5
1
1
9
13,595
fastai/fastai
fastai_fastai/fastai/text/data.py
fastai.text.data.SortedDL
@delegates(TfmdDL) class SortedDL(TfmdDL): """A `DataLoader` that goes throught the item in the order given by `sort_func`""" def __init__(self, dataset, sort_func=None, res=None, **kwargs): super().__init__(dataset, **kwargs) self.sort_func = _default_sort if sort_func is None else sort_func ...
@delegates(TfmdDL) class SortedDL(TfmdDL): '''A `DataLoader` that goes throught the item in the order given by `sort_func`''' def __init__(self, dataset, sort_func=None, res=None, **kwargs): pass def get_idxs(self): pass def shuffle_fn(self, idxs): pass @delegates(TfmdDL.n...
7
1
7
0
7
0
3
0.03
1
3
0
0
4
3
4
4
34
4
29
16
23
1
32
15
27
5
1
1
13
13,596
fastai/fastai
fastai_fastai/fastai/text/data.py
fastai.text.data.TensorText
class TensorText(TensorBase): pass
class TensorText(TensorBase): pass
1
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
0
1
1
1
0
2
1
1
0
1
0
0
13,597
fastai/fastai
fastai_fastai/fastai/text/data.py
fastai.text.data.TextBlock
class TextBlock(TransformBlock): """A `TransformBlock` for texts""" @delegates(Numericalize.__init__) def __init__(self, tok_tfm, vocab=None, is_lm=False, seq_len=72, backwards=False, **kwargs): type_tfms = [tok_tfm, Numericalize(vocab, **kwargs)] if backwards: type_tfms += [rev...
class TextBlock(TransformBlock): '''A `TransformBlock` for texts''' @delegates(Numericalize.__init__) def __init__(self, tok_tfm, vocab=None, is_lm=False, seq_len=72, backwards=False, **kwargs): pass @classmethod @delegates(Tokenizer.from_df, keep=True) def from_df(cls, text_cols, vocab=...
9
3
5
0
4
1
2
0.17
1
6
5
0
1
0
3
3
23
2
18
8
9
3
10
5
6
4
1
1
6
13,598
fastai/fastai
fastai_fastai/fastai/text/data.py
fastai.text.data.TextDataLoaders
class TextDataLoaders(DataLoaders): """Basic wrapper around several `DataLoader`s with factory methods for NLP problems""" @classmethod @delegates(DataLoaders.from_dblock) def from_folder(cls, path, train='train', valid='valid', valid_pct=None, seed=None, vocab=None, text_vocab=None, is_lm=False, tok_t...
class TextDataLoaders(DataLoaders): '''Basic wrapper around several `DataLoader`s with factory methods for NLP problems''' @classmethod @delegates(DataLoaders.from_dblock) def from_folder(cls, path, train='train', valid='valid', valid_pct=None, seed=None, vocab=None, text_vocab=None, is_lm=False, tok_tf...
9
4
10
0
9
1
5
0.12
1
5
3
0
0
0
3
3
39
2
33
16
22
4
22
11
18
7
1
1
14
13,599
fastai/fastai
fastai_fastai/fastai/text/learner.py
fastai.text.learner.LMLearner
class LMLearner(TextLearner): """Add functionality to `TextLearner` when dealing with a language model""" def predict(self, text, n_words=1, no_unk=True, temperature=1.0, min_p=None, no_bar=False, decoder=decode_spec_tokens, only_last_word=False): """Return `text` and the `n_words` that come after""" ...
class LMLearner(TextLearner): '''Add functionality to `TextLearner` when dealing with a language model''' def predict(self, text, n_words=1, no_unk=True, temperature=1.0, min_p=None, no_bar=False, decoder=decode_spec_tokens, only_last_word=False): '''Return `text` and the `n_words` that come after''' ...
4
2
12
1
11
1
5
0.08
1
2
0
0
2
0
2
7
28
2
24
14
20
2
28
12
25
9
2
3
10