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,400
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.ImageInfo
from pikepdf import Dictionary, Matrix, Name, Object, Page, Pdf, PdfImage, PdfInlineImage, Stream, UnsupportedImageTypeError, parse_content_stream from ocrmypdf.helpers import Resolution, available_cpu_count, pikepdf_enable_mmap from decimal import Decimal class ImageInfo: """Information about an image found in a ...
class ImageInfo: '''Information about an image found in a PDF. This gathers information from pikepdf and pdfminer.six, and is pickle-able so that it can be passed to a worker process, unlike objects from those libraries. ''' def __init__(self, *, name='', pdfimage: Object | None=None, inline: ...
26
14
11
1
8
3
3
0.32
0
11
3
0
14
8
14
14
192
27
125
46
92
40
87
25
72
14
0
2
36
13,401
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.InlineSettings
from pikepdf import Dictionary, Matrix, Name, Object, Page, Pdf, PdfImage, PdfInlineImage, Stream, UnsupportedImageTypeError, parse_content_stream from typing import NamedTuple class InlineSettings(NamedTuple): """Info about an inline image found in a PDF.""" iimage: PdfInlineImage shorthand: tuple[float, ...
class InlineSettings(NamedTuple): '''Info about an inline image found in a PDF.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
13,402
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.PageInfo
from ocrmypdf.helpers import Resolution, available_cpu_count, pikepdf_enable_mmap from collections.abc import Callable, Container, Iterable, Iterator, Mapping, Sequence from pikepdf import Dictionary, Matrix, Name, Object, Page, Pdf, PdfImage, PdfInlineImage, Stream, UnsupportedImageTypeError, parse_content_stream from...
class PageInfo: '''Information about type of contents on each page in a PDF.''' def __init__(self, pdf: Pdf, pageno: int, infile: PathLike, check_pages: Container[int], detailed_analysis: bool=False, miner_state: PdfMinerState | None=None): '''Initialize a PageInfo object.''' pass def _ga...
41
21
10
1
8
2
2
0.2
0
17
7
0
22
14
22
22
269
42
191
96
132
38
131
61
107
10
0
3
45
13,403
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.PageResolutionProfile
from typing import NamedTuple class PageResolutionProfile(NamedTuple): """Information about the resolutions of a page.""" weighted_dpi: float 'The weighted average DPI of the page, weighted by the area of each image.' max_dpi: float 'The maximum DPI of an image on the page.' average_to_max_dpi_...
class PageResolutionProfile(NamedTuple): '''Information about the resolutions of a page.''' pass
1
1
0
0
0
0
0
2.4
1
0
0
0
0
0
0
0
24
7
5
1
4
12
5
1
4
0
1
0
0
13,404
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.PdfInfo
from contextlib import contextmanager, nullcontext from pathlib import Path from ocrmypdf.exceptions import EncryptedPdfError, InputFileError from collections.abc import Callable, Container, Iterable, Iterator, Mapping, Sequence from ocrmypdf.pdfinfo.layout import LTStateAwareChar, PdfMinerState, get_page_analysis, get...
class PdfInfo: '''Extract summary information about a PDF without retaining the PDF itself. Crucially this lets us get the information in a pure Python format so that it can be pickled and passed to a worker process. ''' def __init__(self, infile: Path, *, detailed_analysis: bool=False, progbar: b...
21
13
7
0
6
1
2
0.25
0
12
4
0
12
4
12
12
119
16
83
41
52
21
46
21
33
7
0
3
19
13,405
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.TextMarker
class TextMarker: """Sentinel indicating text drawing operations were found on a page."""
class TextMarker: '''Sentinel indicating text drawing operations were found on a page.''' pass
1
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
2
0
1
1
0
1
1
1
0
0
0
0
0
13,406
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.TextboxInfo
from typing import NamedTuple class TextboxInfo(NamedTuple): """Info about a text box found in a PDF.""" bbox: tuple[float, float, float, float] is_visible: bool is_corrupt: bool
class TextboxInfo(NamedTuple): '''Info about a text box found in a PDF.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
13,407
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.VectorMarker
class VectorMarker: """Sentinel indicating vector drawing operations were found on a page."""
class VectorMarker: '''Sentinel indicating vector drawing operations were found on a page.''' pass
1
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
2
0
1
1
0
1
1
1
0
0
0
0
0
13,408
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/info.py
ocrmypdf.pdfinfo.info.XobjectSettings
from typing import NamedTuple class XobjectSettings(NamedTuple): """Info about an XObject found in a PDF.""" name: str shorthand: tuple[float, float, float, float, float, float] stack_depth: int
class XobjectSettings(NamedTuple): '''Info about an XObject found in a PDF.''' pass
1
1
0
0
0
0
0
0.25
1
0
0
0
0
0
0
0
6
1
4
1
3
1
4
1
3
0
1
0
0
13,409
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/layout.py
ocrmypdf.pdfinfo.layout.LTStateAwareChar
from pdfminer.pdfinterp import PDFGraphicState, PDFResourceManager, PDFTextState from pdfminer.pdffont import FontWidthDict, PDFFont, PDFSimpleFont, PDFUnicodeNotDefined from pdfminer.layout import LAParams, LTChar, LTPage, LTTextBox from pdfminer.pdfcolor import PDFColorSpace from pdfminer.utils import Matrix, bbox2st...
class LTStateAwareChar(LTChar): '''A subclass of LTChar that tracks text render mode at time of drawing.''' def __init__(self, matrix: Matrix, font: PDFFont, fontsize: float, scaling: float, rise: float, text: str, textwidth: float, textdisp: float | tuple[float | None, float], ncs: PDFColorSpace, graphicstat...
5
5
15
0
13
3
2
0.16
1
6
0
0
4
1
4
4
83
6
67
21
49
11
18
8
13
3
1
1
7
13,410
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/layout.py
ocrmypdf.pdfinfo.layout.PdfMinerState
import pdfminer.psparser import pdfminer.pdfinterp from pathlib import Path import pdfminer from ocrmypdf.exceptions import EncryptedPdfError, InputFileError import pdfminer.encodingdb from pdfminer.layout import LAParams, LTChar, LTPage, LTTextBox import pdfminer.pdfdevice from pdfminer.pdfpage import PDFPage class P...
class PdfMinerState: '''Provide a context manager for using pdfminer.six. This ensures that the file is closed. It also provides a cache of pages from the PDF so that they can be reused if needed, to improve performance. ''' def __init__(self, infile: Path, pscript5_mode: bool) -> None: ''...
5
5
11
1
8
2
2
0.3
0
8
3
0
5
6
5
5
65
9
43
17
37
13
34
16
28
5
0
3
11
13,411
jbarlow83/OCRmyPDF
src/ocrmypdf/pdfinfo/layout.py
ocrmypdf.pdfinfo.layout.TextPositionTracker
from pdfminer.pdfdevice import PDFTextSeq from pdfminer.layout import LAParams, LTChar, LTPage, LTTextBox from pdfminer.pdfcolor import PDFColorSpace from pdfminer.pdfinterp import PDFGraphicState, PDFResourceManager, PDFTextState from pdfminer.utils import Matrix, bbox2str, matrix2str from pdfminer.pdfpage import PDFP...
class TextPositionTracker(PDFLayoutAnalyzer): '''A page layout analyzer that pays attention to text visibility.''' def __init__(self, rsrcmgr: PDFResourceManager, pageno: int=1, laparams: LAParams | None=None): '''Initialize the layout analyzer.''' pass def begin_page(self, page: PDFPage,...
8
8
10
0
9
1
1
0.12
1
6
1
0
7
2
7
7
82
8
66
35
37
8
33
14
25
2
1
1
9
13,412
jbarlow83/OCRmyPDF
src/ocrmypdf/pluginspec.py
ocrmypdf.pluginspec.OcrEngine
from argparse import ArgumentParser, Namespace from collections.abc import Sequence, Set from abc import ABC, abstractmethod from pathlib import Path class OcrEngine(ABC): """A class representing an OCR engine with capabilities similar to Tesseract OCR. This could be used to create a plugin for another OCR en...
class OcrEngine(ABC): '''A class representing an OCR engine with capabilities similar to Tesseract OCR. This could be used to create a plugin for another OCR engine instead of Tesseract OCR. ''' @staticmethod @abstractmethod def version() -> str: '''Returns the version of the OCR en...
23
9
9
1
2
6
1
1.79
1
6
1
3
1
0
8
28
97
19
28
21
1
50
10
9
1
1
4
0
8
13,413
jbarlow83/OCRmyPDF
src/ocrmypdf/pluginspec.py
ocrmypdf.pluginspec.OrientationConfidence
from typing import TYPE_CHECKING, NamedTuple class OrientationConfidence(NamedTuple): """Expresses an OCR engine's confidence in page rotation. Attributes: angle: The clockwise angle (0, 90, 180, 270) that the page should be rotated. 0 means no rotation. confidence: How confident t...
class OrientationConfidence(NamedTuple): '''Expresses an OCR engine's confidence in page rotation. Attributes: angle: The clockwise angle (0, 90, 180, 270) that the page should be rotated. 0 means no rotation. confidence: How confident the OCR engine is that this the correct ...
1
1
0
0
0
0
0
2.33
1
0
0
0
0
0
0
0
12
2
3
1
2
7
3
1
2
0
1
0
0
13,414
jbarlow83/OCRmyPDF
src/ocrmypdf/quality.py
ocrmypdf.quality.OcrQualityDictionary
import re from collections.abc import Iterable class OcrQualityDictionary: """Manages a dictionary for simple OCR quality checks.""" def __init__(self, *, wordlist: Iterable[str]): """Construct a dictionary from a list of words. Words for which capitalization is important should be capitalize...
class OcrQualityDictionary: '''Manages a dictionary for simple OCR quality checks.''' def __init__(self, *, wordlist: Iterable[str]): '''Construct a dictionary from a list of words. Words for which capitalization is important should be capitalized in the dictionary. Words that contain ...
3
3
16
2
9
5
3
0.58
0
4
0
0
2
1
2
2
36
6
19
9
16
11
16
9
13
4
0
2
5
13,415
jbarlow83/OCRmyPDF
tests/plugins/tesseract_badutf8.py
tesseract_badutf8.BadUtf8OcrEngine
from ocrmypdf.builtin_plugins.tesseract_ocr import TesseractOcrEngine class BadUtf8OcrEngine(TesseractOcrEngine): @staticmethod def generate_hocr(input_file, output_hocr, output_text, options): with patch_tesseract_run(): TesseractOcrEngine.generate_hocr(input_file, output_hocr, output_tex...
class BadUtf8OcrEngine(TesseractOcrEngine): @staticmethod def generate_hocr(input_file, output_hocr, output_text, options): pass @staticmethod def generate_pdf(input_file, output_pdf, output_text, options): pass
5
0
5
0
5
0
1
0
1
0
0
0
0
0
2
38
14
1
13
5
8
0
7
3
4
1
6
1
2
13,416
jbarlow83/OCRmyPDF
tests/plugins/tesseract_big_image_error.py
tesseract_big_image_error.BigImageErrorOcrEngine
from ocrmypdf.builtin_plugins.tesseract_ocr import TesseractOcrEngine class BigImageErrorOcrEngine(TesseractOcrEngine): @staticmethod def get_orientation(input_file, options): with patch_tesseract_run(): return TesseractOcrEngine.get_orientation(input_file, options) @staticmethod ...
class BigImageErrorOcrEngine(TesseractOcrEngine): @staticmethod def get_orientation(input_file, options): pass @staticmethod def generate_hocr(input_file, output_hocr, output_text, options): pass @staticmethod def generate_pdf(input_file, output_pdf, output_text, options): ...
7
0
4
0
4
0
1
0
1
0
0
0
0
0
3
39
19
2
17
7
10
0
10
4
6
1
6
1
3
13,417
jbarlow83/OCRmyPDF
tests/plugins/tesseract_cache.py
tesseract_cache.CacheOcrEngine
from unittest.mock import patch from functools import partial from ocrmypdf.builtin_plugins.tesseract_ocr import TesseractOcrEngine import threading class CacheOcrEngine(TesseractOcrEngine): lock = threading.Lock() @staticmethod def get_orientation(input_file, options): with CacheOcrEngine.lock, p...
class CacheOcrEngine(TesseractOcrEngine): @staticmethod def get_orientation(input_file, options): pass @staticmethod def get_deskew(input_file, options) -> float: pass @staticmethod def generate_hocr(input_file, output_hocr, output_text, options): pass @staticmethod...
9
0
7
0
7
0
1
0.12
1
2
0
0
0
0
4
40
42
4
34
10
25
4
14
6
9
1
6
1
4
13,418
jbarlow83/OCRmyPDF
tests/plugins/tesseract_crash.py
tesseract_crash.CrashOcrEngine
from ocrmypdf.builtin_plugins.tesseract_ocr import TesseractOcrEngine class CrashOcrEngine(TesseractOcrEngine): @staticmethod def get_orientation(input_file, options): with patch_tesseract_run(): return TesseractOcrEngine.get_orientation(input_file, options) @staticmethod def gene...
class CrashOcrEngine(TesseractOcrEngine): @staticmethod def get_orientation(input_file, options): pass @staticmethod def generate_hocr(input_file, output_hocr, output_text, options): pass @staticmethod def generate_pdf(input_file, output_pdf, output_text, options): pass
7
0
4
0
4
0
1
0
1
0
0
0
0
0
3
39
19
2
17
7
10
0
10
4
6
1
6
1
3
13,419
jbarlow83/OCRmyPDF
tests/plugins/tesseract_debug_rotate.py
tesseract_debug_rotate.FixedRotateNoopOcrEngine
import pikepdf from ocrmypdf.helpers import page_number from ocrmypdf import OcrEngine, OrientationConfidence, hookimpl from PIL import Image class FixedRotateNoopOcrEngine(OcrEngine): @staticmethod def version(): return '4.1.1' @staticmethod def creator_tag(options): tag = '-PDF' if ...
class FixedRotateNoopOcrEngine(OcrEngine): @staticmethod def version(): pass @staticmethod def creator_tag(options): pass def __str__(self): pass @staticmethod def languages(options): pass @staticmethod def get_orientation(input_file, options): ...
14
0
5
0
4
0
1
0
1
2
1
0
1
0
7
35
46
8
38
25
24
0
29
16
21
2
5
1
8
13,420
jbarlow83/OCRmyPDF
tests/plugins/tesseract_noop.py
tesseract_noop.NoopOcrEngine
from ocrmypdf import OcrEngine, OrientationConfidence, hookimpl from PIL import Image import pikepdf class NoopOcrEngine(OcrEngine): @staticmethod def version(): return '4.1.1' @staticmethod def creator_tag(options): tag = '-PDF' if options.pdf_renderer == 'sandwich' else '-hOCR' ...
class NoopOcrEngine(OcrEngine): @staticmethod def version(): pass @staticmethod def creator_tag(options): pass def __str__(self): pass @staticmethod def languages(options): pass @staticmethod def get_orientation(input_file, options): pass ...
16
0
4
0
4
0
1
0
1
2
1
0
1
0
8
36
46
7
39
25
23
0
29
15
20
2
5
1
9
13,421
jbarlow83/OCRmyPDF
tests/plugins/tesseract_simulate_oom_killer.py
tesseract_simulate_oom_killer.Page4Engine
import signal from pathlib import Path import os class Page4Engine(NoopOcrEngine): def __str__(self): return f'NO-OP Page 4 {NoopOcrEngine.version()}' @staticmethod def generate_hocr(input_file: Path, output_hocr, output_text, options): if input_file.stem.startswith('000004'): ...
class Page4Engine(NoopOcrEngine): def __str__(self): pass @staticmethod def generate_hocr(input_file: Path, output_hocr, output_text, options): pass @staticmethod def generate_pdf(input_file, output_pdf, output_text, options): pass
6
0
6
0
5
1
2
0.16
1
1
0
0
1
0
3
3
23
2
19
6
13
3
11
4
7
2
1
1
5
13,422
jbarlow83/OCRmyPDF
misc/watcher.py
watcher.HandleObserverEvent
from pathlib import Path from watchdog.events import PatternMatchingEventHandler class HandleObserverEvent(PatternMatchingEventHandler): def __init__(self, patterns=None, ignore_patterns=None, ignore_directories=False, case_sensitive=False, settings={}): super().__init__(patterns=patterns, ignore_patterns...
class HandleObserverEvent(PatternMatchingEventHandler): def __init__(self, patterns=None, ignore_patterns=None, ignore_directories=False, case_sensitive=False, settings={}): pass def on_any_event(self, event): pass
3
0
9
0
9
1
2
0.05
1
2
0
0
2
1
2
2
20
1
19
11
9
1
7
4
4
2
1
1
3
13,423
jbarlow83/OCRmyPDF
misc/watcher.py
watcher.LoggingLevelEnum
from enum import Enum class LoggingLevelEnum(str, Enum): """Enum for logging levels.""" DEBUG = 'DEBUG' INFO = 'INFO' WARNING = 'WARNING' ERROR = 'ERROR' CRITICAL = 'CRITICAL'
class LoggingLevelEnum(str, Enum): '''Enum for logging levels.''' pass
1
1
0
0
0
0
0
0.17
2
0
0
0
0
0
0
115
8
1
6
6
5
1
6
6
5
0
4
0
0
13,424
fastai/fastai
fastai_fastai/dev_nbs/course/crappify.py
crappify.crappifier
from PIL import Image, ImageDraw, ImageFont class crappifier: def __init__(self, path_lr, path_hr): self.path_lr = path_lr self.path_hr = path_hr def __call__(self, fn): dest = self.path_lr / fn.relative_to(self.path_hr) dest.parent.mkdir(parents=True, exist_ok=True) i...
class crappifier: def __init__(self, path_lr, path_hr): pass def __call__(self, fn): pass
3
0
7
0
7
0
1
0
0
1
0
0
2
2
2
2
15
1
14
10
11
0
14
10
11
1
0
0
2
13,425
fastai/fastai
fastai_fastai/nbs/dltest.py
dltest.RandDL
class RandDL(DataLoader): def create_item(self, s): r = random.random() return r if r < 0.95 else stop()
class RandDL(DataLoader): def create_item(self, s): pass
2
0
3
0
3
0
2
0
1
0
0
0
1
0
1
21
4
0
4
3
2
0
4
3
2
2
2
0
2
13,426
fastai/fastai
fastai_fastai/fastai/callback/azureml.py
fastai.callback.azureml.AzureMLCallback
import warnings from ..learner import Callback from azureml.core.run import Run from azureml.exceptions import RunEnvironmentException class AzureMLCallback(Callback): """ Log losses, metrics, model architecture summary to AzureML. If `log_offline` is False, will only log if actually running on AzureML. ...
class AzureMLCallback(Callback): ''' Log losses, metrics, model architecture summary to AzureML. If `log_offline` is False, will only log if actually running on AzureML. A custom AzureML `Run` class can be passed as `azurerun`. If `log_to_parent` is True, will also log to the parent run, if exists ...
6
1
9
0
8
1
3
0.24
1
6
0
0
5
2
5
10
58
7
41
16
35
10
40
15
34
4
2
3
16
13,427
fastai/fastai
fastai_fastai/fastai/callback/captum.py
fastai.callback.captum.CaptumInterpretation
from captum.attr import IntegratedGradients, NoiseTunnel, GradientShap, Occlusion from matplotlib.colors import LinearSegmentedColormap from captum.attr import visualization as viz class CaptumInterpretation: """Captum Interpretation for Resnet""" def __init__(self, learn, cmap_name='custom blue', colors=None...
class CaptumInterpretation: '''Captum Interpretation for Resnet''' def __init__(self, learn, cmap_name='custom blue', colors=None, N=256, methods=('original_image', 'heat_map'), signs=('all', 'positive'), outlier_perc=1): pass def get_baseline_img(self, img_tensor, baseline_type): pass ...
7
1
9
0
9
0
3
0.06
0
4
1
0
6
11
6
6
61
7
52
27
44
3
42
23
35
8
0
1
18
13,428
fastai/fastai
fastai_fastai/fastai/callback/channelslast.py
fastai.callback.channelslast.ChannelsLast
class ChannelsLast(Callback): """Channels last training using PyTorch's Channels Last Memory Format (beta)""" order = -1 def before_fit(self): self.learn.model.to(memory_format=torch.channels_last)
class ChannelsLast(Callback): '''Channels last training using PyTorch's Channels Last Memory Format (beta)''' def before_fit(self): pass
2
1
2
0
2
0
1
0.5
1
0
0
0
1
0
1
1
5
0
4
3
2
2
4
3
2
1
1
0
1
13,429
fastai/fastai
fastai_fastai/fastai/callback/comet.py
fastai.callback.comet.CometCallback
import tempfile import comet_ml from ..learner import Callback class CometCallback(Callback): """Log losses, metrics, model weights, model architecture summary to neptune""" order = Recorder.order + 1 def __init__(self, project_name, log_model_weights=True): self.log_model_weights = log_model_weig...
class CometCallback(Callback): '''Log losses, metrics, model weights, model architecture summary to neptune''' def __init__(self, project_name, log_model_weights=True): pass def before_fit(self): pass def after_batch(self): pass def after_epoch(self): pass d...
6
1
13
1
12
1
4
0.07
1
5
0
0
5
4
5
10
74
9
61
17
55
4
50
15
44
6
2
3
18
13,430
fastai/fastai
fastai_fastai/fastai/callback/core.py
fastai.callback.core.Callback
@funcs_kwargs(as_method=True) class Callback(Stateful, GetAttr): """Basic class handling tweaks of the training loop by changing a `Learner` in various events""" order, _default, learn, run, run_train, run_valid = (0, 'learn', None, True, True, True) _methods = _events def __init__(self, **kwargs): ...
@funcs_kwargs(as_method=True) class Callback(Stateful, GetAttr): '''Basic class handling tweaks of the training loop by changing a `Learner` in various events''' def __init__(self, **kwargs): pass def __repr__(self): pass def __call__(self, event_name): '''Call `self.{event_na...
8
4
4
0
4
1
2
0.23
2
3
0
16
5
0
5
5
30
4
22
12
17
5
26
10
20
5
1
2
10
13,431
fastai/fastai
fastai_fastai/fastai/callback/core.py
fastai.callback.core.FetchPredsCallback
class FetchPredsCallback(Callback): """A callback to fetch predictions during the training loop""" remove_on_fetch = True def __init__(self, ds_idx: int=1, dl: DataLoader=None, with_input: bool=False, with_decoded: bool=False, cbs: Callback | MutableSequence=None, reorder: bool=True): self.cbs = L(...
class FetchPredsCallback(Callback): '''A callback to fetch predictions during the training loop''' def __init__(self, ds_idx: int=1, dl: DataLoader=None, with_input: bool=False, with_decoded: bool=False, cbs: Callback | MutableSequence=None, reorder: bool=True): pass def after_validate(self): ...
3
2
8
0
8
4
1
0.47
1
4
1
0
2
6
2
7
20
1
17
16
7
8
9
7
6
1
2
1
2
13,432
fastai/fastai
fastai_fastai/fastai/callback/core.py
fastai.callback.core.GatherPredsCallback
class GatherPredsCallback(Callback): """`Callback` that returns all predictions and targets, optionally `with_input` or `with_loss`""" _stateattrs = ('preds', 'targets', 'inputs', 'losses') def __init__(self, with_input: bool=False, with_loss: bool=False, save_preds: Path=None, save_targs: Path=None, with_...
class GatherPredsCallback(Callback): '''`Callback` that returns all predictions and targets, optionally `with_input` or `with_loss`''' def __init__(self, with_input: bool=False, with_loss: bool=False, save_preds: Path=None, save_targs: Path=None, with_preds: bool=True, with_targs: bool=True, concat_dim: int=0,...
7
6
8
0
7
2
4
0.33
1
5
0
0
6
9
6
11
54
5
43
27
27
14
47
15
40
8
2
1
25
13,433
fastai/fastai
fastai_fastai/fastai/callback/core.py
fastai.callback.core.TrainEvalCallback
from ..losses import BaseLoss class TrainEvalCallback(Callback): """`Callback` that tracks the number of iterations done and properly sets training/eval mode""" order, run_valid = (-10, False) def after_create(self): self.learn.n_epoch = 1 def before_fit(self): """Set the iter and epo...
class TrainEvalCallback(Callback): '''`Callback` that tracks the number of iterations done and properly sets training/eval mode''' def after_create(self): pass def before_fit(self): '''Set the iter and epoch counters to 0, put the model and the right device''' pass def after_...
6
5
4
0
4
1
1
0.25
1
1
1
0
5
0
5
10
29
4
20
8
15
5
23
8
17
3
2
1
7
13,434
fastai/fastai
fastai_fastai/fastai/callback/data.py
fastai.callback.data.CollectDataCallback
class CollectDataCallback(Callback): """Collect all batches, along with `pred` and `loss`, into `self.data`. Mainly for testing""" def before_fit(self): self.data = L() def after_batch(self): self.data.append(self.learn.to_detach((self.xb, self.yb, self.pred, self.loss)))
class CollectDataCallback(Callback): '''Collect all batches, along with `pred` and `loss`, into `self.data`. Mainly for testing''' def before_fit(self): pass def after_batch(self): pass
3
1
2
0
2
0
1
0.25
1
0
0
0
2
1
2
2
5
0
4
3
2
1
5
4
2
1
1
0
2
13,435
fastai/fastai
fastai_fastai/fastai/callback/data.py
fastai.callback.data.PartialDL
@delegates() class PartialDL(TfmdDL): """Select randomly partial quantity of data at each epoch""" def __init__(self, dataset=None, bs=None, partial_n=None, **kwargs): super().__init__(dataset=dataset, bs=bs, **kwargs) self.partial_n = min(partial_n, self.n) if partial_n else None def get_...
@delegates() class PartialDL(TfmdDL): '''Select randomly partial quantity of data at each epoch''' def __init__(self, dataset=None, bs=None, partial_n=None, **kwargs): pass def get_idxs(self): pass def __len__(self): pass
5
1
3
0
3
0
2
0.1
1
2
0
0
3
2
3
3
13
2
10
6
6
1
12
5
8
3
1
1
7
13,436
fastai/fastai
fastai_fastai/fastai/callback/data.py
fastai.callback.data.WeightedDL
@delegates() class WeightedDL(TfmdDL): """Weighted dataloader where `wgts` is used for the training set only""" def __init__(self, dataset=None, bs=None, wgts=None, **kwargs): wgts = array([1.0] * len(dataset) if wgts is None else wgts) self.wgts = wgts / wgts.sum() super().__init__(dat...
@delegates() class WeightedDL(TfmdDL): '''Weighted dataloader where `wgts` is used for the training set only''' def __init__(self, dataset=None, bs=None, wgts=None, **kwargs): pass def get_idxs(self): pass
4
1
4
0
4
0
3
0.11
1
2
0
0
2
2
2
2
11
1
9
5
6
1
11
4
8
3
1
1
5
13,437
fastai/fastai
fastai_fastai/fastai/callback/fp16.py
fastai.callback.fp16.AMPMode
class AMPMode(Enum): """Automatic mixed precision modes for ease of completion""" FP16 = 'fp16' BF16 = 'bf16'
class AMPMode(Enum): '''Automatic mixed precision modes for ease of completion''' pass
1
1
0
0
0
0
0
0.33
1
0
0
0
0
0
0
0
4
0
3
3
2
1
3
3
2
0
1
0
0
13,438
fastai/fastai
fastai_fastai/fastai/callback/fp16.py
fastai.callback.fp16.MixedPrecision
from torch.amp import GradScaler, autocast @delegates(GradScaler) class MixedPrecision(Callback): """Mixed precision training using Pytorch's Automatic Mixed Precision (AMP)""" order = 10 def __init__(self, amp_mode: str | AMPMode=AMPMode.FP16, **kwargs): amp_mode = AMPMode(amp_mode) store...
@delegates(GradScaler) class MixedPrecision(Callback): '''Mixed precision training using Pytorch's Automatic Mixed Precision (AMP)''' def __init__(self, amp_mode: str | AMPMode=AMPMode.FP16, **kwargs): pass def before_fit(self): pass def before_batch(self): pass def after...
14
4
3
0
3
0
1
0.16
1
4
1
0
11
4
11
11
45
3
37
21
26
6
37
17
25
4
1
2
15
13,439
fastai/fastai
fastai_fastai/fastai/callback/fp16.py
fastai.callback.fp16.ModelToHalf
from ..fp16_utils import convert_network, model_grads_to_master_grads, master_params_to_model_params class ModelToHalf(Callback): """Use with NonNativeMixedPrecision callback (but it needs to run at the very beginning)""" order = -50 def before_fit(self): self.learn.model = convert_network(self.mo...
class ModelToHalf(Callback): '''Use with NonNativeMixedPrecision callback (but it needs to run at the very beginning)''' def before_fit(self): pass def after_fit(self): pass
3
1
1
0
1
0
1
0.25
1
0
0
0
2
1
2
2
5
0
4
4
3
1
6
4
3
1
1
0
2
13,440
fastai/fastai
fastai_fastai/fastai/callback/fp16.py
fastai.callback.fp16.NonNativeMixedPrecision
@docs class NonNativeMixedPrecision(Callback): """Run training in mixed precision""" order = 10 def __init__(self, loss_scale: int=512, flat_master: bool=False, dynamic: bool=True, max_loss_scale: float=2.0 ** 24, div_factor: float=2.0, scale_wait: int=500, clip: float=None): assert torch.backends....
@docs class NonNativeMixedPrecision(Callback): '''Run training in mixed precision''' def __init__(self, loss_scale: int=512, flat_master: bool=False, dynamic: bool=True, max_loss_scale: float=2.0 ** 24, div_factor: float=2.0, scale_wait: int=500, clip: float=None): pass def before_fit(self): ...
11
1
6
0
6
2
2
0.24
1
3
0
0
9
11
9
9
72
6
62
29
47
15
56
21
46
9
1
3
22
13,441
fastai/fastai
fastai_fastai/fastai/callback/hook.py
fastai.callback.hook.ActivationStats
@delegates() class ActivationStats(HookCallback): """Callback that record the mean and std of activations.""" order = -20 def __init__(self, with_hist=False, **kwargs): super().__init__(**kwargs) self.with_hist = with_hist def before_fit(self): """Initialize stats.""" s...
@delegates() class ActivationStats(HookCallback): '''Callback that record the mean and std of activations.''' def __init__(self, with_hist=False, **kwargs): pass def before_fit(self): '''Initialize stats.''' pass def hook(self, m, i, o): pass def hook_multi_ouput(...
12
6
5
0
4
1
2
0.13
1
3
0
0
10
2
10
18
61
9
46
25
35
6
51
24
40
3
2
2
19
13,442
fastai/fastai
fastai_fastai/fastai/callback/hook.py
fastai.callback.hook.Hook
@docs class Hook: """Create a hook on `m` with `hook_func`.""" def __init__(self, m, hook_func, is_forward=True, detach=True, cpu=False, gather=False): store_attr('hook_func,detach,cpu,gather') f = m.register_forward_hook if is_forward else m.register_backward_hook self.hook = f(self.ho...
@docs class Hook: '''Create a hook on `m` with `hook_func`.''' def __init__(self, m, hook_func, is_forward=True, detach=True, cpu=False, gather=False): pass def hook_fn(self, module, input, output): '''Applies `hook_func` to `module`, `input`, `output`.''' pass def remove(self...
7
3
3
0
3
0
2
0.17
0
0
0
0
5
5
5
5
25
4
18
11
14
3
19
10
13
2
0
1
8
13,443
fastai/fastai
fastai_fastai/fastai/callback/hook.py
fastai.callback.hook.HookCallback
@funcs_kwargs class HookCallback(Callback): """`Callback` that can be used to register hooks on `modules`""" _methods = ['hook'] hook = noops def __init__(self, modules=None, every=None, remove_end=True, is_forward=True, detach=True, cpu=True, include_paramless=False, **kwargs): store_attr('mod...
@funcs_kwargs class HookCallback(Callback): '''`Callback` that can be used to register hooks on `modules`''' def __init__(self, modules=None, every=None, remove_end=True, is_forward=True, detach=True, cpu=True, include_paramless=False, **kwargs): pass def before_fit(self): '''Register the ...
10
3
3
0
2
0
2
0.14
1
1
1
1
8
2
8
8
30
6
21
12
14
3
31
13
22
3
1
1
16
13,444
fastai/fastai
fastai_fastai/fastai/callback/hook.py
fastai.callback.hook.Hooks
@docs class Hooks: """Create several hooks on the modules in `ms` with `hook_func`.""" def __init__(self, ms, hook_func, is_forward=True, detach=True, cpu=False): self.hooks = [Hook(m, hook_func, is_forward, detach, cpu) for m in ms] def __getitem__(self, i): return self.hooks[i] def ...
@docs class Hooks: '''Create several hooks on the modules in `ms` with `hook_func`.''' def __init__(self, ms, hook_func, is_forward=True, detach=True, cpu=False): pass def __getitem__(self, i): pass def __len__(self): pass def __iter__(self): pass @property ...
11
2
1
0
1
0
1
0.13
0
1
1
0
8
1
8
8
21
4
15
13
11
2
19
12
10
2
0
1
9
13,445
fastai/fastai
fastai_fastai/fastai/callback/mixup.py
fastai.callback.mixup.CutMix
class CutMix(MixHandler): """Implementation of https://arxiv.org/abs/1905.04899""" def __init__(self, alpha: float=1.0): super().__init__(alpha) def before_batch(self): """Add `rand_bbox` patches with size based on `lam` and location chosen randomly.""" bs, _, H, W = self.x.size() ...
class CutMix(MixHandler): '''Implementation of https://arxiv.org/abs/1905.04899''' def __init__(self, alpha: float=1.0): pass def before_batch(self): '''Add `rand_bbox` patches with size based on `lam` and location chosen randomly.''' pass def rand_bbox(self, W: int, H: int, l...
4
3
11
0
10
3
1
0.29
1
4
0
0
3
3
3
9
37
2
31
26
21
9
25
19
21
2
2
1
4
13,446
fastai/fastai
fastai_fastai/fastai/callback/mixup.py
fastai.callback.mixup.MixHandler
from torch.distributions.beta import Beta class MixHandler(Callback): """A handler class for implementing `MixUp` style scheduling""" run_valid = False def __init__(self, alpha: float=0.5): self.distrib = Beta(tensor(alpha), tensor(alpha)) def before_train(self): """Determine whether ...
class MixHandler(Callback): '''A handler class for implementing `MixUp` style scheduling''' def __init__(self, alpha: float=0.5): pass def before_train(self): '''Determine whether to stack y''' pass def after_train(self): '''Set the loss function back to the previous ...
7
6
4
0
3
1
2
0.35
1
3
1
2
6
3
6
6
31
5
20
15
11
7
21
12
14
2
1
1
9
13,447
fastai/fastai
fastai_fastai/fastai/callback/mixup.py
fastai.callback.mixup.MixUp
class MixUp(MixHandler): """Implementation of https://arxiv.org/abs/1710.09412""" def __init__(self, alpha: float=0.4): super().__init__(alpha) def before_batch(self): """Blend xb and yb with another random item in a second batch (xb1,yb1) with `lam` weights""" lam = self.distrib.s...
class MixUp(MixHandler): '''Implementation of https://arxiv.org/abs/1710.09412''' def __init__(self, alpha: float=0.4): pass def before_batch(self): '''Blend xb and yb with another random item in a second batch (xb1,yb1) with `lam` weights''' pass
3
2
9
1
8
1
2
0.19
1
3
0
0
2
4
2
8
20
2
16
13
11
3
14
9
11
2
2
1
3
13,448
fastai/fastai
fastai_fastai/fastai/callback/preds.py
fastai.callback.preds.MCDropoutCallback
class MCDropoutCallback(Callback): def before_validate(self): for m in [m for m in flatten_model(self.model) if 'dropout' in m.__class__.__name__.lower()]: m.train() def after_validate(self): for m in [m for m in flatten_model(self.model) if 'dropout' in m.__class__.__name__.lower(...
class MCDropoutCallback(Callback): def before_validate(self): pass def after_validate(self): pass
3
0
3
0
3
0
2
0
1
0
0
0
2
0
2
2
8
1
7
5
4
0
7
5
4
2
1
1
4
13,449
fastai/fastai
fastai_fastai/fastai/callback/progress.py
fastai.callback.progress.CSVLogger
class CSVLogger(Callback): """Log the results displayed in `learn.path/fname`""" order = 60 def __init__(self, fname='history.csv', append=False): self.fname, self.append = (Path(fname), append) def read_log(self): """Convenience method to quickly access the log.""" return pd.r...
class CSVLogger(Callback): '''Log the results displayed in `learn.path/fname`''' def __init__(self, fname='history.csv', append=False): pass def read_log(self): '''Convenience method to quickly access the log.''' pass def before_fit(self): '''Prepare file with metric n...
6
5
5
0
4
1
2
0.24
1
2
0
0
5
4
5
5
30
4
21
10
15
5
23
10
17
3
1
1
8
13,450
fastai/fastai
fastai_fastai/fastai/callback/progress.py
fastai.callback.progress.ProgressCallback
@docs class ProgressCallback(Callback): """A `Callback` to handle the display of progress bars""" order, _stateattrs = (60, ('mbar', 'pbar')) def before_fit(self): assert hasattr(self.learn, 'recorder') if self.create_mbar: self.mbar = master_bar(list(range(self.n_epoch))) ...
@docs class ProgressCallback(Callback): '''A `Callback` to handle the display of progress bars''' def before_fit(self): pass def before_epoch(self): pass def before_train(self): pass def before_validate(self): pass def after_train(self): pass def...
12
1
3
0
3
0
2
0.03
1
4
0
0
10
5
10
10
44
7
36
16
29
1
38
16
27
3
1
1
18
13,451
fastai/fastai
fastai_fastai/fastai/callback/progress.py
fastai.callback.progress.ShowGraphCallback
class ShowGraphCallback(Callback): """Update a graph of training and validation loss""" order, run_valid = (65, False) def before_fit(self): self.run = not hasattr(self.learn, 'lr_finder') and (not hasattr(self, 'gather_preds')) if not self.run: return self.nb_batches = ...
class ShowGraphCallback(Callback): '''Update a graph of training and validation loss''' def before_fit(self): pass def after_train(self): pass def after_epoch(self): '''Plot validation loss in the pbar graph''' pass
4
2
5
0
5
0
2
0.13
1
0
0
0
3
2
3
3
21
3
16
12
13
2
19
12
15
2
1
1
5
13,452
fastai/fastai
fastai_fastai/fastai/callback/rnn.py
fastai.callback.rnn.ModelResetter
@docs class ModelResetter(Callback): """`Callback` that resets the model at each validation/training step""" def before_train(self): self.model.reset() def before_validate(self): self.model.reset() def after_fit(self): self.model.reset() _docs = dict(before_train='Reset th...
@docs class ModelResetter(Callback): '''`Callback` that resets the model at each validation/training step''' def before_train(self): pass def before_validate(self): pass def after_fit(self): pass
5
1
1
0
1
0
1
0.14
1
0
0
0
3
0
3
3
8
0
7
5
6
1
8
5
4
1
1
0
3
13,453
fastai/fastai
fastai_fastai/fastai/callback/rnn.py
fastai.callback.rnn.RNNCallback
class RNNCallback(Callback): """Save the raw and dropped-out outputs and only keep the true output for loss computation""" def after_pred(self): self.learn.pred, self.raw_out, self.out = [o[-1] if is_listy(o) else o for o in self.pred]
class RNNCallback(Callback): '''Save the raw and dropped-out outputs and only keep the true output for loss computation''' def after_pred(self): pass
2
1
1
0
1
0
2
0.5
1
0
0
0
1
2
1
1
3
0
2
2
1
1
3
3
1
2
1
0
2
13,454
fastai/fastai
fastai_fastai/fastai/callback/rnn.py
fastai.callback.rnn.RNNRegularizer
class RNNRegularizer(Callback): """Add AR and TAR regularization""" order, run_valid = (RNNCallback.order + 1, False) def __init__(self, alpha=0.0, beta=0.0): store_attr() def after_loss(self): if not self.training: return if self.alpha: self.learn.loss_...
class RNNRegularizer(Callback): '''Add AR and TAR regularization''' def __init__(self, alpha=0.0, beta=0.0): pass def after_loss(self): pass
3
1
4
0
4
0
3
0.11
1
0
0
0
2
0
2
2
10
0
9
5
7
1
13
5
10
5
1
2
6
13,455
fastai/fastai
fastai_fastai/fastai/callback/schedule.py
fastai.callback.schedule.LRFinder
@docs class LRFinder(ParamScheduler): """Training with exponentially growing learning rate""" def __init__(self, start_lr=1e-07, end_lr=10, num_it=100, stop_div=True): if num_it < 6: num_it = 6 self.scheds = {'lr': [SchedExp(s, e) for s, e in zip(start_lr, end_lr)] if is_listy(start...
@docs class LRFinder(ParamScheduler): '''Training with exponentially growing learning rate''' def __init__(self, start_lr=1e-07, end_lr=10, num_it=100, stop_div=True): pass def before_fit(self): pass def before_batch(self): pass def after_batch(self): pass de...
8
1
4
0
4
0
2
0.06
1
5
0
0
6
6
6
12
39
6
32
15
27
2
33
15
26
4
2
1
12
13,456
fastai/fastai
fastai_fastai/fastai/callback/schedule.py
fastai.callback.schedule.ParamScheduler
@docs class ParamScheduler(Callback): """Schedule hyper-parameters according to `scheds`""" order, run_valid = (60, False) def __init__(self, scheds): self.scheds = scheds def before_fit(self): self.hps = {p: [] for p in self.scheds.keys()} def before_batch(self): self._up...
@docs class ParamScheduler(Callback): '''Schedule hyper-parameters according to `scheds`''' def __init__(self, scheds): pass def before_fit(self): pass def before_batch(self): pass def _update_val(self, pct): pass def after_batch(self): pass def ...
8
1
2
0
2
0
2
0.07
1
0
0
1
6
3
6
6
21
5
15
12
11
1
18
13
11
2
1
1
9
13,457
fastai/fastai
fastai_fastai/fastai/callback/schedule.py
fastai.callback.schedule._Annealer
class _Annealer: def __init__(self, f, start, end): store_attr('f,start,end') def __call__(self, pos): return self.f(self.start, self.end, pos)
class _Annealer: def __init__(self, f, start, end): pass def __call__(self, pos): pass
3
0
1
0
1
0
1
0
0
0
0
0
2
0
2
2
3
0
3
3
2
0
5
3
2
1
0
0
2
13,458
fastai/fastai
fastai_fastai/fastai/callback/tensorboard.py
fastai.callback.tensorboard.TensorBoardBaseCallback
from torch.utils.tensorboard import SummaryWriter from .hook import hook_output class TensorBoardBaseCallback(Callback): order = Recorder.order + 1 'Base class for tensorboard callbacks' def __init__(self): self.run_projector = False def after_pred(self): if self.run_projector: ...
class TensorBoardBaseCallback(Callback): def __init__(self): pass def after_pred(self): pass def after_validate(self): pass def after_fit(self): pass def _setup_projector(self): pass def _setup_writer(self): pass def __del__(self): ...
9
0
2
0
2
0
2
0.05
1
0
0
2
8
4
8
8
26
5
20
12
14
1
27
14
18
2
1
1
13
13,459
fastai/fastai
fastai_fastai/fastai/callback/tensorboard.py
fastai.callback.tensorboard.TensorBoardCallback
class TensorBoardCallback(TensorBoardBaseCallback): """Saves model topology, losses & metrics for tensorboard and tensorboard projector during training""" def __init__(self, log_dir=None, trace_model=True, log_preds=True, n_preds=9, projector=False, layer=None): super().__init__() store_attr() ...
class TensorBoardCallback(TensorBoardBaseCallback): '''Saves model topology, losses & metrics for tensorboard and tensorboard projector during training''' def __init__(self, log_dir=None, trace_model=True, log_preds=True, n_preds=9, projector=False, layer=None): pass def before_fit(self): ...
6
1
6
0
6
0
3
0.03
1
4
0
0
5
1
5
13
35
4
30
15
24
1
33
15
27
4
2
2
13
13,460
fastai/fastai
fastai_fastai/fastai/callback/tensorboard.py
fastai.callback.tensorboard.TensorBoardProjectorCallback
class TensorBoardProjectorCallback(TensorBoardBaseCallback): """Extracts and exports image featuers for tensorboard projector during inference""" def __init__(self, log_dir=None, layer=None): super().__init__() store_attr() def before_fit(self): self.run = not hasattr(self.learn, '...
class TensorBoardProjectorCallback(TensorBoardBaseCallback): '''Extracts and exports image featuers for tensorboard projector during inference''' def __init__(self, log_dir=None, layer=None): pass def before_fit(self): pass def before_validate(self): pass
4
1
3
0
3
0
1
0.1
1
1
0
0
3
1
3
11
13
2
10
5
6
1
11
5
7
2
2
1
4
13,461
fastai/fastai
fastai_fastai/fastai/callback/tracker.py
fastai.callback.tracker.EarlyStoppingCallback
class EarlyStoppingCallback(TrackerCallback): """A `TrackerCallback` that terminates training when monitored quantity stops improving.""" order = TrackerCallback.order + 3 def __init__(self, monitor='valid_loss', comp=None, min_delta=0.0, patience=1, reset_on_fit=True): super().__init__(monitor=mon...
class EarlyStoppingCallback(TrackerCallback): '''A `TrackerCallback` that terminates training when monitored quantity stops improving.''' def __init__(self, monitor='valid_loss', comp=None, min_delta=0.0, patience=1, reset_on_fit=True): pass def before_fit(self): pass def after_epoch(...
4
2
6
0
6
2
2
0.35
1
1
0
0
3
3
3
7
23
1
20
13
11
7
16
7
12
3
2
2
5
13,462
fastai/fastai
fastai_fastai/fastai/callback/tracker.py
fastai.callback.tracker.ReduceLROnPlateau
class ReduceLROnPlateau(TrackerCallback): """A `TrackerCallback` that reduces learning rate when a metric has stopped improving.""" order = TrackerCallback.order + 2 def __init__(self, monitor='valid_loss', comp=None, min_delta=0.0, patience=1, factor=10.0, min_lr=0, reset_on_fit=True): super().__i...
class ReduceLROnPlateau(TrackerCallback): '''A `TrackerCallback` that reduces learning rate when a metric has stopped improving.''' def __init__(self, monitor='valid_loss', comp=None, min_delta=0.0, patience=1, factor=10.0, min_lr=0, reset_on_fit=True): pass def before_fit(self): pass ...
4
2
8
0
8
3
2
0.36
1
1
0
0
3
5
3
7
28
1
25
17
14
9
20
9
16
5
2
3
7
13,463
fastai/fastai
fastai_fastai/fastai/callback/tracker.py
fastai.callback.tracker.SaveModelCallback
class SaveModelCallback(TrackerCallback): """A `TrackerCallback` that saves the model's best during training and loads it at the end.""" order = TrackerCallback.order + 1 def __init__(self, monitor='valid_loss', comp=None, min_delta=0.0, fname='model', every_epoch=False, at_end=False, with_opt=False, reset...
class SaveModelCallback(TrackerCallback): '''A `TrackerCallback` that saves the model's best during training and loads it at the end.''' def __init__(self, monitor='valid_loss', comp=None, min_delta=0.0, fname='model', every_epoch=False, at_end=False, with_opt=False, reset_on_fit=True): pass def _...
5
3
7
0
7
3
2
0.46
1
1
0
0
4
2
4
8
35
3
28
17
15
13
21
7
16
4
2
2
9
13,464
fastai/fastai
fastai_fastai/fastai/callback/tracker.py
fastai.callback.tracker.TerminateOnNaNCallback
class TerminateOnNaNCallback(Callback): """A `Callback` that terminates training if loss is NaN.""" order = -9 def after_batch(self): """Test if `last_loss` is NaN and interrupts training.""" if torch.isinf(self.loss) or torch.isnan(self.loss): raise CancelFitException
class TerminateOnNaNCallback(Callback): '''A `Callback` that terminates training if loss is NaN.''' def after_batch(self): '''Test if `last_loss` is NaN and interrupts training.''' pass
2
2
3
0
2
1
2
0.5
1
0
0
0
1
0
1
1
6
0
4
3
2
2
5
3
3
2
1
1
2
13,465
fastai/fastai
fastai_fastai/fastai/callback/tracker.py
fastai.callback.tracker.TrackerCallback
class TrackerCallback(Callback): """A `Callback` that keeps track of the best value in `monitor`.""" order, remove_on_fetch, _only_train_loop = (60, True, True) def __init__(self, monitor='valid_loss', comp=None, min_delta=0.0, reset_on_fit=True): if comp is None: comp = np.less if 'los...
class TrackerCallback(Callback): '''A `Callback` that keeps track of the best value in `monitor`.''' def __init__(self, monitor='valid_loss', comp=None, min_delta=0.0, reset_on_fit=True): pass def before_fit(self): '''Prepare the monitored value''' pass def after_epoch(self): ...
5
3
5
0
5
2
3
0.33
1
2
0
3
4
8
4
4
27
3
21
16
12
7
21
11
16
4
1
1
10
13,466
fastai/fastai
fastai_fastai/fastai/callback/training.py
fastai.callback.training.BnFreeze
class BnFreeze(Callback): run_after = TrainEvalCallback 'Freeze moving average statistics in all non-trainable batchnorm layers.' def before_train(self): set_bn_eval(self.model)
class BnFreeze(Callback): def before_train(self): pass
2
0
2
0
2
0
1
0.25
1
0
0
0
1
0
1
1
5
0
4
3
2
1
4
3
2
1
1
0
1
13,467
fastai/fastai
fastai_fastai/fastai/callback/training.py
fastai.callback.training.GradientAccumulation
class GradientAccumulation(Callback): """Accumulate gradients before updating weights""" order, run_valid = (MixedPrecision.order - 4, False) def __init__(self, n_acc=32): store_attr() def before_fit(self): self.count = 0 def after_loss(self): self.learn.loss_grad /= self....
class GradientAccumulation(Callback): '''Accumulate gradients before updating weights''' def __init__(self, n_acc=32): pass def before_fit(self): pass def after_loss(self): pass def before_step(self): '''Skip weight update if we have not seen enough items''' ...
5
2
2
0
2
1
1
0.4
1
0
0
0
4
1
4
4
12
0
10
6
8
4
14
7
9
2
1
1
5
13,468
fastai/fastai
fastai_fastai/fastai/callback/training.py
fastai.callback.training.GradientClip
class GradientClip(Callback): """Clip norm of gradients""" order = MixedPrecision.order + 1 def __init__(self, max_norm: float=1.0, norm_type: float=2.0): store_attr() def before_step(self): nn.utils.clip_grad_norm_(self.parameters(), self.max_norm, self.norm_type)
class GradientClip(Callback): '''Clip norm of gradients''' def __init__(self, max_norm: float=1.0, norm_type: float=2.0): pass def before_step(self): pass
3
1
1
0
1
0
1
0.25
1
1
0
0
2
0
2
2
5
0
4
4
3
1
6
4
3
1
1
0
2
13,469
fastai/fastai
fastai_fastai/fastai/callback/training.py
fastai.callback.training.ShortEpochCallback
class ShortEpochCallback(Callback): """Fit just `pct` of an epoch, then stop""" def __init__(self, pct=0.01, short_valid=True): self.pct, self.short_valid = (pct, short_valid) def after_batch(self): if self.iter / self.n_iter < self.pct: return if self.training: ...
class ShortEpochCallback(Callback): '''Fit just `pct` of an epoch, then stop''' def __init__(self, pct=0.01, short_valid=True): pass def after_batch(self): pass
3
1
3
0
3
0
3
0.17
1
0
0
0
2
2
2
2
7
0
6
3
4
1
10
4
7
4
1
1
5
13,470
fastai/fastai
fastai_fastai/fastai/callback/wandb.py
fastai.callback.wandb.WandbCallback
import wandb from .tracker import SaveModelCallback from ..tabular.all import TabularDataLoaders, Tabular class WandbCallback(Callback): """Saves model topology, losses & metrics""" remove_on_fetch, order = (True, Recorder.order + 1) _wandb_watch_called = False def __init__(self, log: str=None, log_pr...
class WandbCallback(Callback): '''Saves model topology, losses & metrics''' def __init__(self, log: str=None, log_preds: bool=True, log_preds_every_epoch: bool=False, log_model: bool=False, model_name: str=None, log_dataset: bool=False, dataset_name: str=None, valid_dl: TfmdDL=None, n_preds: int=36, seed: int...
9
4
15
1
13
3
4
0.27
1
14
4
0
8
11
8
13
139
17
107
45
87
29
94
30
85
14
2
4
31
13,471
fastai/fastai
fastai_fastai/fastai/collab.py
fastai.collab.CollabDataLoaders
class CollabDataLoaders(DataLoaders): """Base `DataLoaders` for collaborative filtering.""" @delegates(DataLoaders.from_dblock) @classmethod def from_df(cls, ratings, valid_pct=0.2, user_name=None, item_name=None, rating_name=None, seed=None, path='.', **kwargs): """Create a `DataLoaders` suita...
class CollabDataLoaders(DataLoaders): '''Base `DataLoaders` for collaborative filtering.''' @delegates(DataLoaders.from_dblock) @classmethod def from_df(cls, ratings, valid_pct=0.2, user_name=None, item_name=None, rating_name=None, seed=None, path='.', **kwargs): '''Create a `DataLoaders` suitab...
6
3
6
0
5
1
1
0.21
1
3
3
0
0
0
2
16
18
1
14
8
8
3
11
6
8
1
2
0
2
13,472
fastai/fastai
fastai_fastai/fastai/collab.py
fastai.collab.EmbeddingDotBias
class EmbeddingDotBias(Module): """Base dot model for collaborative filtering.""" def __init__(self, n_factors, n_users, n_items, y_range=None): self.y_range = y_range self.u_weight, self.i_weight, self.u_bias, self.i_bias = [Embedding(*o) for o in [(n_users, n_factors), (n_items, n_factors), (...
class EmbeddingDotBias(Module): '''Base dot model for collaborative filtering.''' def __init__(self, n_factors, n_users, n_items, y_range=None): pass def forward(self, x): pass @classmethod def from_classes(cls, n_factors, classes, user=None, item=None, y_range=None): '''Bu...
8
5
6
0
6
1
2
0.14
1
4
1
0
5
5
6
18
45
5
35
23
27
5
36
20
29
4
2
1
14
13,473
fastai/fastai
fastai_fastai/fastai/collab.py
fastai.collab.EmbeddingNN
class EmbeddingNN(TabularModel): """Subclass `TabularModel` to create a NN suitable for collaborative filtering.""" @delegates(TabularModel.__init__) def __init__(self, emb_szs, layers, **kwargs): super().__init__(emb_szs=emb_szs, n_cont=0, out_sz=1, layers=layers, **kwargs)
class EmbeddingNN(TabularModel): '''Subclass `TabularModel` to create a NN suitable for collaborative filtering.''' @delegates(TabularModel.__init__) def __init__(self, emb_szs, layers, **kwargs): pass
3
1
2
0
2
0
1
0.25
1
1
0
0
1
0
1
15
5
0
4
3
1
1
3
2
1
1
3
0
1
13,474
fastai/fastai
fastai_fastai/fastai/collab.py
fastai.collab.TabularCollab
class TabularCollab(TabularPandas): """Instance of `TabularPandas` suitable for collaborative filtering (with no continuous variable)""" with_cont = False
class TabularCollab(TabularPandas): '''Instance of `TabularPandas` suitable for collaborative filtering (with no continuous variable)''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
24
3
0
2
2
1
1
2
2
1
0
3
0
0
13,475
fastai/fastai
fastai_fastai/fastai/data/block.py
fastai.data.block.DataBlock
@docs @funcs_kwargs class DataBlock: """Generic container to quickly build `Datasets` and `DataLoaders`.""" get_x = get_items = splitter = get_y = None blocks, dl_type = ((TransformBlock, TransformBlock), TfmdDL) _methods = 'get_items splitter get_y get_x'.split() _msg = "If you wanted to compose se...
@docs @funcs_kwargs class DataBlock: '''Generic container to quickly build `Datasets` and `DataLoaders`.''' def __init__(self, blocks: list=None, dl_type: TfmdDL=None, getters: list=None, n_inp: int=None, item_tfms: list=None, batch_tfms: list=None, **kwargs): pass def _combine_type_tfms(self): ...
10
1
12
0
11
3
3
0.22
0
11
4
0
5
9
6
6
86
8
77
50
46
17
56
25
49
11
0
2
19
13,476
fastai/fastai
fastai_fastai/fastai/data/block.py
fastai.data.block.TransformBlock
class TransformBlock: """A basic wrapper that links defaults transforms for the data block API""" def __init__(self, type_tfms: list=None, item_tfms: list=None, batch_tfms: list=None, dl_type: TfmdDL=None, dls_kwargs: dict=None): self.type_tfms = L(type_tfms) self.item_tfms = ToTensor + L(item_...
class TransformBlock: '''A basic wrapper that links defaults transforms for the data block API''' def __init__(self, type_tfms: list=None, item_tfms: list=None, batch_tfms: list=None, dl_type: TfmdDL=None, dls_kwargs: dict=None): pass
2
1
11
0
11
5
2
0.5
0
4
2
0
1
5
1
1
13
0
12
12
4
6
6
6
4
2
0
0
2
13,477
fastai/fastai
fastai_fastai/fastai/data/core.py
fastai.data.core.DataLoaders
@docs class DataLoaders(GetAttr): """Basic wrapper around several `DataLoader`s.""" _default = 'train' def __init__(self, *loaders, path: str | Path='.', device=None): self.loaders, self.path = (list(loaders), Path(path)) if device is not None and (loaders != () and hasattr(loaders[0], 'to'...
@docs class DataLoaders(GetAttr): '''Basic wrapper around several `DataLoader`s.''' def __init__(self, *loaders, path: str | Path='.', device=None): pass def __getitem__(self, i): pass def __len__(self): pass def new_empty(self): pass def _set(i, self, v): ...
20
3
5
0
5
2
2
0.28
1
10
1
3
12
3
14
14
97
11
83
59
42
23
52
27
37
4
1
1
21
13,478
fastai/fastai
fastai_fastai/fastai/data/core.py
fastai.data.core.Datasets
@docs @delegates(TfmdLists) class Datasets(FilteredBase): """A dataset that creates a tuple from each `tfms`""" def __init__(self, items: list=None, tfms: MutableSequence | Pipeline=None, tls: TfmdLists=None, n_inp: int=None, dl_type=None, **kwargs): super().__init__(dl_type=dl_type) self.tls =...
@docs @delegates(TfmdLists) class Datasets(FilteredBase): '''A dataset that creates a tuple from each `tfms`''' def __init__(self, items: list=None, tfms: MutableSequence | Pipeline=None, tls: TfmdLists=None, n_inp: int=None, dl_type=None, **kwargs): pass def __getitem__(self, it): pass ...
26
1
2
0
2
0
1
0.11
1
9
1
0
18
3
18
23
59
5
53
39
35
6
50
27
31
3
1
2
24
13,479
fastai/fastai
fastai_fastai/fastai/data/core.py
fastai.data.core.FilteredBase
class FilteredBase: """Base class for lists with subsets""" _dl_type, _dbunch_type = (TfmdDL, DataLoaders) def __init__(self, *args, dl_type=None, **kwargs): if dl_type is not None: self._dl_type = dl_type self.dataloaders = delegates(self._dl_type.__init__)(self.dataloaders) ...
class FilteredBase: '''Base class for lists with subsets''' def __init__(self, *args, dl_type=None, **kwargs): pass @property def n_subsets(self): pass def _new(self, items, **kwargs): pass def subset(self): pass def dataloaders(self, bs: int=64, shuffle_t...
7
1
7
0
7
2
2
0.32
0
10
2
3
5
0
5
5
41
2
38
25
21
12
31
11
25
7
0
1
12
13,480
fastai/fastai
fastai_fastai/fastai/data/core.py
fastai.data.core.TfmdDL
class TfmdDL(DataLoader): """Transformed `DataLoader`""" @delegates(DataLoader.__init__) def __init__(self, dataset, bs: int=64, shuffle: bool=False, num_workers: int=None, verbose: bool=False, do_setup: bool=True, **kwargs): if num_workers is None: num_workers = min(16, defaults.cpus) ...
null
16
5
9
0
8
2
3
0.26
1
9
0
2
12
4
12
32
119
10
104
69
56
27
82
31
69
5
2
2
34
13,481
fastai/fastai
fastai_fastai/fastai/data/core.py
fastai.data.core.TfmdLists
class TfmdLists(FilteredBase, L, GetAttr): """A `Pipeline` of `tfms` applied to a collection of `items`""" _default = 'tfms' def __init__(self, items: list, tfms: MutableSequence | Pipeline, use_list: bool=None, do_setup: bool=True, split_idx: int=None, train_setup: bool=True, splits: list=None, types=None...
class TfmdLists(FilteredBase, L, GetAttr): '''A `Pipeline` of `tfms` applied to a collection of `items`''' def __init__(self, items: list, tfms: MutableSequence | Pipeline, use_list: bool=None, do_setup: bool=True, split_idx: int=None, train_setup: bool=True, splits: list=None, types=None, verbose: bool=False,...
16
1
4
0
4
1
2
0.19
3
13
1
0
15
5
15
20
74
5
67
42
47
13
69
27
53
6
1
2
30
13,482
fastai/fastai
fastai_fastai/fastai/data/external.py
fastai.data.external.URLs
class URLs: """Global constants for dataset and model URLs.""" LOCAL_PATH = Path.cwd() MDL = 'http://files.fast.ai/models/' GOOGLE = 'https://storage.googleapis.com/' S3 = 'https://s3.amazonaws.com/fast-ai-' URL = f'{S3}sample/' S3_IMAGE = f'{S3}imageclas/' S3_IMAGELOC = f'{S3}imagelocal...
class URLs: '''Global constants for dataset and model URLs.''' def path(url: str='.', c_key: str='archive') -> Path: '''Local path where to download based on `c_key`''' pass
2
2
9
0
8
3
3
0.17
0
2
0
0
1
0
1
1
98
10
77
75
72
13
75
72
73
3
0
1
3
13,483
fastai/fastai
fastai_fastai/fastai/data/load.py
fastai.data.load.DataLoader
@funcs_kwargs class DataLoader(GetAttr): _noop_methods = 'wif before_iter after_item before_batch after_batch after_iter'.split() for o in _noop_methods: exec(f'def {o}(self, x=None, *args, **kwargs): return x') _methods = _noop_methods + 'create_batches create_item create_batch retain get_i...
@funcs_kwargs class DataLoader(GetAttr): def __init__(self, dataset=None, bs=None, num_workers=0, pin_memory=False, timeout=0, batch_size=None, shuffle=False, drop_last=False, indexed=None, n=None, device=None, persistent_workers=False, pin_memory_device='', **kwargs): pass def __len__(self): ...
25
0
4
0
4
0
3
0.04
1
17
2
2
20
13
20
20
105
9
94
47
75
4
120
38
99
8
1
5
56
13,484
fastai/fastai
fastai_fastai/fastai/data/load.py
fastai.data.load.SkipItemException
class SkipItemException(Exception): """Raised to notify `DataLoader` to skip an item""" pass
class SkipItemException(Exception): '''Raised to notify `DataLoader` to skip an item''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
10
3
0
2
1
1
1
2
1
1
0
3
0
0
13,485
fastai/fastai
fastai_fastai/fastai/data/load.py
fastai.data.load._FakeLoader
from torch.utils.data.dataloader import _MultiProcessingDataLoaderIter, _SingleProcessDataLoaderIter, _DatasetKind class _FakeLoader: def _fn_noops(self, x=None, *args, **kwargs): return x _IterableDataset_len_called, _auto_collation, collate_fn, drop_last, in_order = (None, False, _fn_noops, False, T...
class _FakeLoader: def _fn_noops(self, x=None, *args, **kwargs): pass def __init__(self, d, pin_memory, num_workers, timeout, persistent_workers, pin_memory_device): pass def __iter__(self): pass @property def multiprocessing_context(self): pass @contextmanage...
8
0
2
0
2
0
1
0
0
0
0
0
5
5
5
5
23
5
18
14
13
0
19
12
13
1
0
1
5
13,486
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.AttrGetter
class AttrGetter(ItemTransform): """Creates a proper transform that applies `attrgetter(nm)` (even on a tuple)""" _retain = False def __init__(self, nm, default=None): store_attr() def encodes(self, x): return getattr(x, self.nm, self.default)
class AttrGetter(ItemTransform): '''Creates a proper transform that applies `attrgetter(nm)` (even on a tuple)''' def __init__(self, nm, default=None): pass def encodes(self, x): pass
3
1
1
0
1
0
1
0.25
1
0
0
0
2
0
2
2
5
0
4
4
3
1
6
4
3
1
1
0
2
13,487
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.Categorize
class Categorize(DisplayedTransform): """Reversible transform of category string to `vocab` id""" loss_func, order = (CrossEntropyLossFlat(), 1) def __init__(self, vocab=None, sort=True, add_na=False): if vocab is not None: vocab = CategoryMap(vocab, sort=sort, add_na=add_na) st...
class Categorize(DisplayedTransform): '''Reversible transform of category string to `vocab` id''' def __init__(self, vocab=None, sort=True, add_na=False): pass def setups(self, dsets): pass def encodes(self, o): pass def decodes(self, o): pass
5
1
3
0
3
0
2
0.07
1
4
3
2
4
3
4
4
17
2
14
9
10
1
17
8
12
2
1
1
7
13,488
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.Category
class Category(str, ShowTitle): _show_args = {'label': 'category'}
class Category(str, ShowTitle): pass
1
0
0
0
0
0
0
0
2
0
0
0
0
0
0
67
1
0
1
1
1
0
2
2
1
0
2
0
0
13,489
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.CategoryMap
class CategoryMap(CollBase): """Collection of categories with the reverse mapping in `o2i`""" def __init__(self, col, sort=True, add_na=False, strict=False): if hasattr(col, 'dtype') and isinstance(col.dtype, CategoricalDtype): items = L(col.cat.categories, use_list=True) if str...
class CategoryMap(CollBase): '''Collection of categories with the reverse mapping in `o2i`''' def __init__(self, col, sort=True, add_na=False, strict=False): pass def map_objs(self, objs): '''Map `objs` to IDs''' pass def map_ids(self, ids): '''Map `ids` to objects in ...
5
3
5
0
4
1
3
0.38
1
2
0
0
4
2
4
4
24
3
16
11
12
6
19
8
14
7
1
2
10
13,490
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.ColReader
class ColReader(DisplayedTransform): """Read `cols` in `row` with potential `pref` and `suff`""" def __init__(self, cols, pref='', suff='', label_delim=None): store_attr() self.pref = str(pref) + os.path.sep if isinstance(pref, Path) else pref self.cols = L(cols) def _do_one(self, ...
class ColReader(DisplayedTransform): '''Read `cols` in `row` with potential `pref` and `suff`''' def __init__(self, cols, pref='', suff='', label_delim=None): pass def _do_one(self, r, c): pass def __call__(self, o, **kwargs): pass
4
1
4
0
4
0
3
0.08
1
3
0
0
3
2
3
3
16
2
13
6
9
1
16
6
12
5
1
1
9
13,491
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.EncodedMultiCategorize
class EncodedMultiCategorize(Categorize): """Transform of one-hot encoded multi-category that decodes with `vocab`""" loss_func, order = (BCEWithLogitsLossFlat(), 1) def __init__(self, vocab): super().__init__(vocab, sort=vocab == None) self.c = len(vocab) def encodes(self, o): ...
class EncodedMultiCategorize(Categorize): '''Transform of one-hot encoded multi-category that decodes with `vocab`''' def __init__(self, vocab): pass def encodes(self, o): pass def decodes(self, o): pass
4
1
2
0
2
0
1
0.14
1
3
2
0
3
1
3
7
8
0
7
6
5
1
9
6
5
1
2
0
3
13,492
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.IntToFloatTensor
class IntToFloatTensor(DisplayedTransform): """Transform image to float tensor, optionally dividing by 255 (e.g. for images).""" order = 10 def __init__(self, div=255.0, div_mask=1): store_attr() def encodes(self, o: TensorImage): return o.float().div_(self.div) def encodes(self, ...
class IntToFloatTensor(DisplayedTransform): '''Transform image to float tensor, optionally dividing by 255 (e.g. for images).''' def __init__(self, div=255.0, div_mask=1): pass def encodes(self, o: TensorImage): pass def encodes(self, o: TensorImage): pass def decodes(sel...
5
1
1
0
1
0
1
0.33
1
2
2
0
4
0
4
4
7
0
6
6
5
2
10
6
5
2
1
0
5
13,493
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.ItemGetter
class ItemGetter(ItemTransform): """Creates a proper transform that applies `itemgetter(i)` (even on a tuple)""" _retain = False def __init__(self, i): self.i = i def encodes(self, x): return x[self.i]
class ItemGetter(ItemTransform): '''Creates a proper transform that applies `itemgetter(i)` (even on a tuple)''' def __init__(self, i): pass def encodes(self, x): pass
3
1
1
0
1
0
1
0.25
1
0
0
0
2
1
2
2
5
0
4
4
3
1
6
5
3
1
1
0
2
13,494
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.MultiCategorize
class MultiCategorize(Categorize): """Reversible transform of multi-category strings to `vocab` id""" loss_func, order = (BCEWithLogitsLossFlat(), 1) def __init__(self, vocab=None, add_na=False): super().__init__(vocab=vocab, add_na=add_na, sort=vocab == None) def setups(self, dsets): ...
class MultiCategorize(Categorize): '''Reversible transform of multi-category strings to `vocab` id''' def __init__(self, vocab=None, add_na=False): pass def setups(self, dsets): pass def encodes(self, o): pass def decodes(self, o): pass
5
1
4
0
4
0
2
0.06
1
7
3
0
4
1
4
8
19
2
16
11
13
1
20
11
15
4
2
2
8
13,495
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.MultiCategory
class MultiCategory(L): def show(self, ctx=None, sep=';', color='black', **kwargs): return show_title(sep.join(self.map(str)), ctx=ctx, color=color, **kwargs)
class MultiCategory(L): def show(self, ctx=None, sep=';', color='black', **kwargs): pass
2
0
2
0
2
0
1
0
1
1
0
0
1
0
1
1
3
0
3
2
1
0
3
2
1
1
1
0
1
13,496
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.Normalize
@docs class Normalize(DisplayedTransform): """Normalize/denorm batch of `TensorImage`""" parameters, order = (L('mean', 'std'), 99) def __init__(self, mean=None, std=None, axes=(0, 2, 3)): store_attr() @classmethod def from_stats(cls, mean, std, dim=1, ndim=4, cuda=True): return cl...
@docs class Normalize(DisplayedTransform): '''Normalize/denorm batch of `TensorImage`''' def __init__(self, mean=None, std=None, axes=(0, 2, 3)): pass @classmethod def from_stats(cls, mean, std, dim=1, ndim=4, cuda=True): pass def setups(self, dl: DataLoader): pass def...
8
1
2
0
2
0
1
0.07
1
2
2
0
4
3
5
5
19
4
14
12
10
1
16
11
10
2
1
1
7
13,497
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.OneHotEncode
class OneHotEncode(DisplayedTransform): """One-hot encodes targets""" order = 2 def __init__(self, c=None): store_attr() def setups(self, dsets): if self.c is None: self.c = len(L(getattr(dsets, 'vocab', None))) if not self.c: warn("Couldn't infer the nu...
class OneHotEncode(DisplayedTransform): '''One-hot encodes targets''' def __init__(self, c=None): pass def setups(self, dsets): pass def encodes(self, o): pass def decodes(self, o): pass
5
1
2
0
2
0
2
0.13
1
1
1
0
4
1
4
4
11
2
8
7
6
1
13
7
8
3
1
1
6
13,498
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.RegexLabeller
import posixpath class RegexLabeller: """Label `item` with regex `pat`.""" def __init__(self, pat, match=False): self.pat = re.compile(pat) self.matcher = self.pat.match if match else self.pat.search def __call__(self, o): o = str(o).replace(os.sep, posixpath.sep) res = se...
class RegexLabeller: '''Label `item` with regex `pat`.''' def __init__(self, pat, match=False): pass def __call__(self, o): pass
3
1
4
0
4
0
2
0.11
0
1
0
0
2
2
2
2
11
1
9
6
6
1
9
6
6
2
0
0
3
13,499
fastai/fastai
fastai_fastai/fastai/data/transforms.py
fastai.data.transforms.RegressionSetup
class RegressionSetup(DisplayedTransform): """Transform that floatifies targets""" loss_func = MSELossFlat() def __init__(self, c=None): store_attr() def encodes(self, o): return tensor(o).float() def decodes(self, o): return TitledFloat(o) if o.ndim == 0 else TitledTuple(...
class RegressionSetup(DisplayedTransform): '''Transform that floatifies targets''' def __init__(self, c=None): pass def encodes(self, o): pass def decodes(self, o): pass def setups(self, dsets): pass
5
1
2
0
2
0
2
0.11
1
2
2
0
4
1
4
4
11
1
9
7
7
1
15
7
10
4
1
1
8