Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
test_result_gather_different_shapes
()
Test that tensors of varying shape get gathered into a list.
Test that tensors of varying shape get gathered into a list.
def test_result_gather_different_shapes(): """ Test that tensors of varying shape get gathered into a list. """ outputs = [ { "foo": torch.tensor(1) }, { "foo": torch.zeros(2, 3) }, { "foo": torch.zeros(1, 2, 3) }, ] res...
[ "def", "test_result_gather_different_shapes", "(", ")", ":", "outputs", "=", "[", "{", "\"foo\"", ":", "torch", ".", "tensor", "(", "1", ")", "}", ",", "{", "\"foo\"", ":", "torch", ".", "zeros", "(", "2", ",", "3", ")", "}", ",", "{", "\"foo\"", "...
[ 244, 0 ]
[ 260, 77 ]
python
en
['en', 'en', 'en']
True
test_result_gather_mixed_types
()
Test that a collection of mixed types gets gathered into a list.
Test that a collection of mixed types gets gathered into a list.
def test_result_gather_mixed_types(): """ Test that a collection of mixed types gets gathered into a list. """ outputs = [ { "foo": 1.2 }, { "foo": ["bar", None] }, { "foo": torch.tensor(1) }, ] result = Result.gather(ou...
[ "def", "test_result_gather_mixed_types", "(", ")", ":", "outputs", "=", "[", "{", "\"foo\"", ":", "1.2", "}", ",", "{", "\"foo\"", ":", "[", "\"bar\"", ",", "None", "]", "}", ",", "{", "\"foo\"", ":", "torch", ".", "tensor", "(", "1", ")", "}", ","...
[ 263, 0 ]
[ 279, 36 ]
python
en
['en', 'en', 'en']
True
MeanSquaredLogError.update
(self, preds: torch.Tensor, target: torch.Tensor)
Update state with predictions and targets. Args: preds: Predictions from model target: Ground truth values
Update state with predictions and targets.
def update(self, preds: torch.Tensor, target: torch.Tensor): """ Update state with predictions and targets. Args: preds: Predictions from model target: Ground truth values """ sum_squared_log_error, n_obs = _mean_squared_log_error_update(preds, target) ...
[ "def", "update", "(", "self", ",", "preds", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ")", ":", "sum_squared_log_error", ",", "n_obs", "=", "_mean_squared_log_error_update", "(", "preds", ",", "target", ")", "self", ".", "sum...
[ 71, 4 ]
[ 82, 27 ]
python
en
['en', 'error', 'th']
False
MeanSquaredLogError.compute
(self)
Compute mean squared logarithmic error over state.
Compute mean squared logarithmic error over state.
def compute(self): """ Compute mean squared logarithmic error over state. """ return _mean_squared_log_error_compute(self.sum_squared_log_error, self.total)
[ "def", "compute", "(", "self", ")", ":", "return", "_mean_squared_log_error_compute", "(", "self", ".", "sum_squared_log_error", ",", "self", ".", "total", ")" ]
[ 84, 4 ]
[ 88, 86 ]
python
en
['en', 'error', 'th']
False
parse_dat
(fname: str, debug: bool = False)
Parse a UKSOFT2001 file.
Parse a UKSOFT2001 file.
def parse_dat(fname: str, debug: bool = False) -> dict[str, Any]: """Parse a UKSOFT2001 file.""" data = {} def parse_block(block, field_dict): for key, (pos, encoding) in field_dict.items(): data[key] = parse_bytes(block, pos, encoding) if debug: print(f"\t{k...
[ "def", "parse_dat", "(", "fname", ":", "str", ",", "debug", ":", "bool", "=", "False", ")", "->", "dict", "[", "str", ",", "Any", "]", ":", "data", "=", "{", "}", "def", "parse_block", "(", "block", ",", "field_dict", ")", ":", "for", "key", ",",...
[ 476, 0 ]
[ 559, 15 ]
python
en
['en', 'ro', 'en']
True
do_ecc_align
( input_img: Image, template_img: Image, max_iter: int = 500, eps: float = 1e-4, trafo: str = "translation", mask: Union[np.ndarray, None] = None, )
Finds warp matrix between two Images using ECC Takes two images and calculates the warp matrix between both applying the transformation specified by 'trafo' using the ECC Algorithm. A optional mask can be given to masked areas of the images that are not taken into account during registration Parameter...
Finds warp matrix between two Images using ECC
def do_ecc_align( input_img: Image, template_img: Image, max_iter: int = 500, eps: float = 1e-4, trafo: str = "translation", mask: Union[np.ndarray, None] = None, ) -> np.ndarray: """Finds warp matrix between two Images using ECC Takes two images and calculates the warp matrix between b...
[ "def", "do_ecc_align", "(", "input_img", ":", "Image", ",", "template_img", ":", "Image", ",", "max_iter", ":", "int", "=", "500", ",", "eps", ":", "float", "=", "1e-4", ",", "trafo", ":", "str", "=", "\"translation\"", ",", "mask", ":", "Union", "[", ...
[ 562, 0 ]
[ 633, 22 ]
python
en
['en', 'nl', 'en']
True
LEEMImg.get_field_string
(self, field: str, fmt: Optional[str] = None)
Get a string that contains the value and its unit. Some LEEM-specific fields have different default formats than the pure DataObject method.
Get a string that contains the value and its unit. Some LEEM-specific fields have different default formats than the pure DataObject method.
def get_field_string(self, field: str, fmt: Optional[str] = None) -> str: """Get a string that contains the value and its unit. Some LEEM-specific fields have different default formats than the pure DataObject method.""" if fmt is None: if field == "temperature": fmt ...
[ "def", "get_field_string", "(", "self", ",", "field", ":", "str", ",", "fmt", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "if", "fmt", "is", "None", ":", "if", "field", "==", "\"temperature\"", ":", "fmt", "=", "\".0f\"", ...
[ 76, 4 ]
[ 84, 51 ]
python
en
['en', 'en', 'en']
True
LEEMImg.normalize
( self, mcp: Image = None, dark_counts: Union[int, float, Image] = 100, inplace: bool = False, )
Normalization of LEEM Images Parameters ---------- mcp : Image, optional [description], by default None dark_counts : Union[int, float, Image], optional [description], by default 100 inplace : bool, optional [description], by default False ...
Normalization of LEEM Images
def normalize( self, mcp: Image = None, dark_counts: Union[int, float, Image] = 100, inplace: bool = False, ) -> LEEMImg: """Normalization of LEEM Images Parameters ---------- mcp : Image, optional [description], by default None da...
[ "def", "normalize", "(", "self", ",", "mcp", ":", "Image", "=", "None", ",", "dark_counts", ":", "Union", "[", "int", ",", "float", ",", "Image", "]", "=", "100", ",", "inplace", ":", "bool", "=", "False", ",", ")", "->", "LEEMImg", ":", "if", "m...
[ 107, 4 ]
[ 145, 21 ]
python
en
['en', 'da', 'en']
True
LEEMStack._single_construct
(self, source: Any)
Construct a single DataObject.
Construct a single DataObject.
def _single_construct(self, source: Any) -> LEEMImg: """Construct a single DataObject.""" return LEEMImg(source, time_origin=self._time_origin)
[ "def", "_single_construct", "(", "self", ",", "source", ":", "Any", ")", "->", "LEEMImg", ":", "return", "LEEMImg", "(", "source", ",", "time_origin", "=", "self", ".", "_time_origin", ")" ]
[ 256, 4 ]
[ 258, 61 ]
python
en
['en', 'en', 'en']
True
LEEMStack.align
( self, inplace: bool = False, mask: Union[bool, np.ndarray, None] = True, **kwargs, )
Image registration of the stack The images of the stack are registered subsequently by calling Image.find_warp_matrix() for each image and finally warping them using Image.warp() Parameters ---------- inplace : bool, default False If 'True' the stack itself...
Image registration of the stack
def align( self, inplace: bool = False, mask: Union[bool, np.ndarray, None] = True, **kwargs, ) -> LEEMStack: """ Image registration of the stack The images of the stack are registered subsequently by calling Image.find_warp_matrix() for each image an...
[ "def", "align", "(", "self", ",", "inplace", ":", "bool", "=", "False", ",", "mask", ":", "Union", "[", "bool", ",", "np", ".", "ndarray", ",", "None", "]", "=", "True", ",", "*", "*", "kwargs", ",", ")", "->", "LEEMStack", ":", "if", "inplace", ...
[ 278, 4 ]
[ 348, 20 ]
python
en
['en', 'error', 'th']
False
LEEMStack.normalize
( self, mcp: Union[Image, str, None] = None, inplace: bool = False, **kwargs )
Normalization of images in stack The images in the stack are normalized by appling Image.normalize(mcp) to each image Parameters ---------- mcp : Image, str or None Image or filename of image if str. If 'None' the mcp attribute of the images will be use...
Normalization of images in stack
def normalize( self, mcp: Union[Image, str, None] = None, inplace: bool = False, **kwargs ) -> LEEMStack: """ Normalization of images in stack The images in the stack are normalized by appling Image.normalize(mcp) to each image Parameters ---------- mcp : Im...
[ "def", "normalize", "(", "self", ",", "mcp", ":", "Union", "[", "Image", ",", "str", ",", "None", "]", "=", "None", ",", "inplace", ":", "bool", "=", "False", ",", "*", "*", "kwargs", ")", "->", "LEEMStack", ":", "# if not a copy funny things might happe...
[ 350, 4 ]
[ 396, 20 ]
python
en
['en', 'error', 'th']
False
IVCurve.__init__
(self, *args, **kwargs)
It is called and behaves exactly like StitchedLine but is called with *xaxis* = "energy" by default. See Also -------- dataobject.StitchedLine
It is called and behaves exactly like StitchedLine but is called with *xaxis* = "energy" by default.
def __init__(self, *args, **kwargs): """ It is called and behaves exactly like StitchedLine but is called with *xaxis* = "energy" by default. See Also -------- dataobject.StitchedLine """ print(*args) print(**kwargs) super().__init__(*args...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "print", "(", "*", "args", ")", "print", "(", "*", "*", "kwargs", ")", "super", "(", ")", ".", "__init__", "(", "*", "args", ",", "*", "*", "kwargs", ",", "x...
[ 404, 4 ]
[ 415, 57 ]
python
en
['en', 'error', 'th']
False
Plugin.connect
( self, model: Module, *args: Sequence, **kwargs: Sequence, )
Connects the plugin with the accelerator (and thereby with trainer and model). Will be called by the accelerator.
Connects the plugin with the accelerator (and thereby with trainer and model). Will be called by the accelerator.
def connect( self, model: Module, *args: Sequence, **kwargs: Sequence, ) -> Optional[Tuple[Module, Sequence, Sequence]]: """Connects the plugin with the accelerator (and thereby with trainer and model). Will be called by the accelerator. """
[ "def", "connect", "(", "self", ",", "model", ":", "Module", ",", "*", "args", ":", "Sequence", ",", "*", "*", "kwargs", ":", "Sequence", ",", ")", "->", "Optional", "[", "Tuple", "[", "Module", ",", "Sequence", ",", "Sequence", "]", "]", ":" ]
[ 24, 4 ]
[ 32, 11 ]
python
en
['en', 'en', 'en']
True
Plugin.pre_dispatch
(self)
Hook to do something before the training/evaluation/prediction starts.
Hook to do something before the training/evaluation/prediction starts.
def pre_dispatch(self) -> None: """Hook to do something before the training/evaluation/prediction starts."""
[ "def", "pre_dispatch", "(", "self", ")", "->", "None", ":" ]
[ 34, 4 ]
[ 35, 84 ]
python
en
['en', 'en', 'en']
True
Plugin.post_dispatch
(self)
Hook to do something after the training/evaluation/prediction finishes.
Hook to do something after the training/evaluation/prediction finishes.
def post_dispatch(self) -> None: """Hook to do something after the training/evaluation/prediction finishes."""
[ "def", "post_dispatch", "(", "self", ")", "->", "None", ":" ]
[ 37, 4 ]
[ 38, 85 ]
python
en
['en', 'en', 'en']
True
Plugin.train_step_context
(self)
A contextmanager for the trainstep
A contextmanager for the trainstep
def train_step_context(self) -> Generator: """A contextmanager for the trainstep""" yield
[ "def", "train_step_context", "(", "self", ")", "->", "Generator", ":", "yield" ]
[ 41, 4 ]
[ 43, 13 ]
python
en
['en', 'en', 'en']
True
Plugin.val_step_context
(self)
A contextmanager for the validation step
A contextmanager for the validation step
def val_step_context(self) -> Generator: """A contextmanager for the validation step""" yield
[ "def", "val_step_context", "(", "self", ")", "->", "Generator", ":", "yield" ]
[ 46, 4 ]
[ 48, 13 ]
python
en
['en', 'en', 'en']
True
Plugin.test_step_context
(self)
A contextmanager for the teststep
A contextmanager for the teststep
def test_step_context(self) -> Generator: """A contextmanager for the teststep""" yield
[ "def", "test_step_context", "(", "self", ")", "->", "Generator", ":", "yield" ]
[ 51, 4 ]
[ 53, 13 ]
python
en
['en', 'en', 'en']
True
Plugin.predict_context
(self)
A contextmanager for the predict step
A contextmanager for the predict step
def predict_context(self) -> Generator: """A contextmanager for the predict step""" yield
[ "def", "predict_context", "(", "self", ")", "->", "Generator", ":", "yield" ]
[ 56, 4 ]
[ 58, 13 ]
python
en
['en', 'en', 'en']
True
get_package_name
(filepath)
Given a path where a package is installed, determine its name. Parameters ---------- filepath : str Path to a file. If the determination fails, "numpy" is returned. Examples -------- >>> np.testing.nosetester.get_package_name('nonsense') 'numpy'
Given a path where a package is installed, determine its name.
def get_package_name(filepath): """ Given a path where a package is installed, determine its name. Parameters ---------- filepath : str Path to a file. If the determination fails, "numpy" is returned. Examples -------- >>> np.testing.nosetester.get_package_name('nonsense') ...
[ "def", "get_package_name", "(", "filepath", ")", ":", "fullpath", "=", "filepath", "[", ":", "]", "pkg_name", "=", "[", "]", "while", "'site-packages'", "in", "filepath", "or", "'dist-packages'", "in", "filepath", ":", "filepath", ",", "p2", "=", "os", "."...
[ 22, 0 ]
[ 60, 29 ]
python
en
['en', 'error', 'th']
False
run_module_suite
(file_to_run=None, argv=None)
Run a test module. Equivalent to calling ``$ nosetests <argv> <file_to_run>`` from the command line Parameters ---------- file_to_run : str, optional Path to test module, or None. By default, run the module from which this function is called. argv : list of strings ...
Run a test module.
def run_module_suite(file_to_run=None, argv=None): """ Run a test module. Equivalent to calling ``$ nosetests <argv> <file_to_run>`` from the command line Parameters ---------- file_to_run : str, optional Path to test module, or None. By default, run the module from which t...
[ "def", "run_module_suite", "(", "file_to_run", "=", "None", ",", "argv", "=", "None", ")", ":", "if", "file_to_run", "is", "None", ":", "f", "=", "sys", ".", "_getframe", "(", "1", ")", "file_to_run", "=", "f", ".", "f_locals", ".", "get", "(", "'__f...
[ 63, 0 ]
[ 111, 58 ]
python
en
['en', 'error', 'th']
False
NoseTester._test_argv
(self, label, verbose, extra_argv)
Generate argv for nosetest command Parameters ---------- label : {'fast', 'full', '', attribute identifier}, optional see ``test`` docstring verbose : int, optional Verbosity value for test outputs, in the range 1-10. Default is 1. extra_argv : list, opt...
Generate argv for nosetest command
def _test_argv(self, label, verbose, extra_argv): ''' Generate argv for nosetest command Parameters ---------- label : {'fast', 'full', '', attribute identifier}, optional see ``test`` docstring verbose : int, optional Verbosity value for test outputs, in...
[ "def", "_test_argv", "(", "self", ",", "label", ",", "verbose", ",", "extra_argv", ")", ":", "argv", "=", "[", "__file__", ",", "self", ".", "package_path", ",", "'-s'", "]", "if", "label", "and", "label", "!=", "'full'", ":", "if", "not", "isinstance"...
[ 197, 4 ]
[ 232, 19 ]
python
en
['en', 'en', 'en']
True
NoseTester._get_custom_doctester
(self)
Return instantiated plugin for doctests Allows subclassing of this class to override doctester A return value of None means use the nose builtin doctest plugin
Return instantiated plugin for doctests
def _get_custom_doctester(self): """ Return instantiated plugin for doctests Allows subclassing of this class to override doctester A return value of None means use the nose builtin doctest plugin """ from .noseclasses import NumpyDoctest return NumpyDoctest()
[ "def", "_get_custom_doctester", "(", "self", ")", ":", "from", ".", "noseclasses", "import", "NumpyDoctest", "return", "NumpyDoctest", "(", ")" ]
[ 254, 4 ]
[ 262, 29 ]
python
en
['en', 'la', 'en']
True
NoseTester.prepare_test_args
(self, label='fast', verbose=1, extra_argv=None, doctests=False, coverage=False, timer=False)
Run tests for module using nose. This method does the heavy lifting for the `test` method. It takes all the same arguments, for details see `test`. See Also -------- test
Run tests for module using nose.
def prepare_test_args(self, label='fast', verbose=1, extra_argv=None, doctests=False, coverage=False, timer=False): """ Run tests for module using nose. This method does the heavy lifting for the `test` method. It takes all the same arguments, for details see `...
[ "def", "prepare_test_args", "(", "self", ",", "label", "=", "'fast'", ",", "verbose", "=", "1", ",", "extra_argv", "=", "None", ",", "doctests", "=", "False", ",", "coverage", "=", "False", ",", "timer", "=", "False", ")", ":", "# fail with nice error mess...
[ 264, 4 ]
[ 326, 28 ]
python
en
['en', 'error', 'th']
False
NoseTester.test
(self, label='fast', verbose=1, extra_argv=None, doctests=False, coverage=False, raise_warnings=None, timer=False)
Run tests for module using nose. Parameters ---------- label : {'fast', 'full', '', attribute identifier}, optional Identifies the tests to run. This can be a string to pass to the nosetests executable with the '-A' option, or one of several special ...
Run tests for module using nose.
def test(self, label='fast', verbose=1, extra_argv=None, doctests=False, coverage=False, raise_warnings=None, timer=False): """ Run tests for module using nose. Parameters ---------- label : {'fast', 'full', '', attribute identifier}, optional ...
[ "def", "test", "(", "self", ",", "label", "=", "'fast'", ",", "verbose", "=", "1", ",", "extra_argv", "=", "None", ",", "doctests", "=", "False", ",", "coverage", "=", "False", ",", "raise_warnings", "=", "None", ",", "timer", "=", "False", ")", ":",...
[ 328, 4 ]
[ 479, 23 ]
python
en
['en', 'error', 'th']
False
NoseTester.bench
(self, label='fast', verbose=1, extra_argv=None)
Run benchmarks for module using nose. Parameters ---------- label : {'fast', 'full', '', attribute identifier}, optional Identifies the benchmarks to run. This can be a string to pass to the nosetests executable with the '-A' option, or one of several ...
Run benchmarks for module using nose.
def bench(self, label='fast', verbose=1, extra_argv=None): """ Run benchmarks for module using nose. Parameters ---------- label : {'fast', 'full', '', attribute identifier}, optional Identifies the benchmarks to run. This can be a string to pass to the n...
[ "def", "bench", "(", "self", ",", "label", "=", "'fast'", ",", "verbose", "=", "1", ",", "extra_argv", "=", "None", ")", ":", "print", "(", "\"Running benchmarks for %s\"", "%", "self", ".", "package_name", ")", "self", ".", "_show_system_info", "(", ")", ...
[ 481, 4 ]
[ 552, 58 ]
python
en
['en', 'error', 'th']
False
OpenIDCode.get_jwt_config
(self, grant)
Get the JWT configuration for OpenIDCode extension. The JWT configuration will be used to generate ``id_token``. { 'key': '', 'alg': '', 'iss': '', 'exp': 3600 } :param grant: AuthorizationCodeGrant instance ...
Get the JWT configuration for OpenIDCode extension. The JWT configuration will be used to generate ``id_token``.
def get_jwt_config(self, grant): # pragma: no cover """Get the JWT configuration for OpenIDCode extension. The JWT configuration will be used to generate ``id_token``. { 'key': '', 'alg': '', 'iss': '', 'exp': 3600 ...
[ "def", "get_jwt_config", "(", "self", ",", "grant", ")", ":", "# pragma: no cover", "return", "self", ".", "jwt_config" ]
[ 85, 4 ]
[ 99, 30 ]
python
en
['en', 'en', 'en']
True
OptimizerConnector.update_learning_rates
(self, interval: str, monitor_metrics=None)
Update learning rates. Args: interval: either 'epoch' or 'step'. monitor_metrics: dict of possible values to monitor
Update learning rates.
def update_learning_rates(self, interval: str, monitor_metrics=None): """Update learning rates. Args: interval: either 'epoch' or 'step'. monitor_metrics: dict of possible values to monitor """ if not self.trainer.lr_schedulers: return for sc...
[ "def", "update_learning_rates", "(", "self", ",", "interval", ":", "str", ",", "monitor_metrics", "=", "None", ")", ":", "if", "not", "self", ".", "trainer", ".", "lr_schedulers", ":", "return", "for", "scheduler_idx", ",", "lr_scheduler", "in", "enumerate", ...
[ 27, 4 ]
[ 85, 21 ]
python
en
['en', 'en', 'en']
True
test_mesh_loss
()
test mesh loss.
test mesh loss.
def test_mesh_loss(): """test mesh loss.""" loss_cfg = dict( type='MeshLoss', joints_2d_loss_weight=1, joints_3d_loss_weight=1, vertex_loss_weight=1, smpl_pose_loss_weight=1, smpl_beta_loss_weight=1, img_res=256, focal_length=5000) loss = buil...
[ "def", "test_mesh_loss", "(", ")", ":", "loss_cfg", "=", "dict", "(", "type", "=", "'MeshLoss'", ",", "joints_2d_loss_weight", "=", "1", ",", "joints_3d_loss_weight", "=", "1", ",", "vertex_loss_weight", "=", "1", ",", "smpl_pose_loss_weight", "=", "1", ",", ...
[ 8, 0 ]
[ 78, 70 ]
python
en
['es', 'hmn', 'en']
False
test_gan_loss
()
test gan loss.
test gan loss.
def test_gan_loss(): """test gan loss.""" with pytest.raises(NotImplementedError): loss_cfg = dict( type='GANLoss', gan_type='test', real_label_val=1.0, fake_label_val=0.0, loss_weight=1) _ = build_loss(loss_cfg) input_1 = torch.on...
[ "def", "test_gan_loss", "(", ")", ":", "with", "pytest", ".", "raises", "(", "NotImplementedError", ")", ":", "loss_cfg", "=", "dict", "(", "type", "=", "'GANLoss'", ",", "gan_type", "=", "'test'", ",", "real_label_val", "=", "1.0", ",", "fake_label_val", ...
[ 81, 0 ]
[ 161, 41 ]
python
ar
['ms', 'ar', 'en']
False
XORCipher.__init__
(self, key=0)
simple constructor that receives a key or uses default key = 0
simple constructor that receives a key or uses default key = 0
def __init__(self, key=0): """ simple constructor that receives a key or uses default key = 0 """ # private field self.__key = key
[ "def", "__init__", "(", "self", ",", "key", "=", "0", ")", ":", "# private field", "self", ".", "__key", "=", "key" ]
[ 22, 4 ]
[ 29, 24 ]
python
en
['en', 'error', 'th']
False
XORCipher.encrypt
(self, content, key)
input: 'content' of type string and 'key' of type int output: encrypted string 'content' as a list of chars if key not passed the method uses the key by the constructor. otherwise key = 1
input: 'content' of type string and 'key' of type int output: encrypted string 'content' as a list of chars if key not passed the method uses the key by the constructor. otherwise key = 1
def encrypt(self, content, key): """ input: 'content' of type string and 'key' of type int output: encrypted string 'content' as a list of chars if key not passed the method uses the key by the constructor. otherwise key = 1 """ # precondition ...
[ "def", "encrypt", "(", "self", ",", "content", ",", "key", ")", ":", "# precondition", "assert", "(", "isinstance", "(", "key", ",", "int", ")", "and", "isinstance", "(", "content", ",", "str", ")", ")", "key", "=", "key", "or", "self", ".", "__key",...
[ 31, 4 ]
[ 54, 18 ]
python
en
['en', 'error', 'th']
False
XORCipher.decrypt
(self, content, key)
input: 'content' of type list and 'key' of type int output: decrypted string 'content' as a list of chars if key not passed the method uses the key by the constructor. otherwise key = 1
input: 'content' of type list and 'key' of type int output: decrypted string 'content' as a list of chars if key not passed the method uses the key by the constructor. otherwise key = 1
def decrypt(self, content, key): """ input: 'content' of type list and 'key' of type int output: decrypted string 'content' as a list of chars if key not passed the method uses the key by the constructor. otherwise key = 1 """ # precondition ...
[ "def", "decrypt", "(", "self", ",", "content", ",", "key", ")", ":", "# precondition", "assert", "(", "isinstance", "(", "key", ",", "int", ")", "and", "isinstance", "(", "content", ",", "list", ")", ")", "key", "=", "key", "or", "self", ".", "__key"...
[ 56, 4 ]
[ 79, 18 ]
python
en
['en', 'error', 'th']
False
XORCipher.encrypt_string
(self, content, key=0)
input: 'content' of type string and 'key' of type int output: encrypted string 'content' if key not passed the method uses the key by the constructor. otherwise key = 1
input: 'content' of type string and 'key' of type int output: encrypted string 'content' if key not passed the method uses the key by the constructor. otherwise key = 1
def encrypt_string(self, content, key=0): """ input: 'content' of type string and 'key' of type int output: encrypted string 'content' if key not passed the method uses the key by the constructor. otherwise key = 1 """ # precondition asser...
[ "def", "encrypt_string", "(", "self", ",", "content", ",", "key", "=", "0", ")", ":", "# precondition", "assert", "(", "isinstance", "(", "key", ",", "int", ")", "and", "isinstance", "(", "content", ",", "str", ")", ")", "key", "=", "key", "or", "sel...
[ 81, 4 ]
[ 104, 18 ]
python
en
['en', 'error', 'th']
False
XORCipher.decrypt_string
(self, content, key=0)
input: 'content' of type string and 'key' of type int output: decrypted string 'content' if key not passed the method uses the key by the constructor. otherwise key = 1
input: 'content' of type string and 'key' of type int output: decrypted string 'content' if key not passed the method uses the key by the constructor. otherwise key = 1
def decrypt_string(self, content, key=0): """ input: 'content' of type string and 'key' of type int output: decrypted string 'content' if key not passed the method uses the key by the constructor. otherwise key = 1 """ # precondition asser...
[ "def", "decrypt_string", "(", "self", ",", "content", ",", "key", "=", "0", ")", ":", "# precondition", "assert", "(", "isinstance", "(", "key", ",", "int", ")", "and", "isinstance", "(", "content", ",", "str", ")", ")", "key", "=", "key", "or", "sel...
[ 106, 4 ]
[ 129, 18 ]
python
en
['en', 'error', 'th']
False
XORCipher.encrypt_file
(self, file, key=0)
input: filename (str) and a key (int) output: returns true if encrypt process was successful otherwise false if key not passed the method uses the key by the constructor. otherwise key = 1
input: filename (str) and a key (int) output: returns true if encrypt process was successful otherwise false if key not passed the method uses the key by the constructor. otherwise key = 1
def encrypt_file(self, file, key=0): """ input: filename (str) and a key (int) output: returns true if encrypt process was successful otherwise false if key not passed the method uses the key by the constructor. otherwise key = 1 """ #...
[ "def", "encrypt_file", "(", "self", ",", "file", ",", "key", "=", "0", ")", ":", "# precondition", "assert", "(", "isinstance", "(", "file", ",", "str", ")", "and", "isinstance", "(", "key", ",", "int", ")", ")", "try", ":", "with", "open", "(", "f...
[ 131, 4 ]
[ 153, 19 ]
python
en
['en', 'error', 'th']
False
XORCipher.decrypt_file
(self, file, key)
input: filename (str) and a key (int) output: returns true if decrypt process was successful otherwise false if key not passed the method uses the key by the constructor. otherwise key = 1
input: filename (str) and a key (int) output: returns true if decrypt process was successful otherwise false if key not passed the method uses the key by the constructor. otherwise key = 1
def decrypt_file(self, file, key): """ input: filename (str) and a key (int) output: returns true if decrypt process was successful otherwise false if key not passed the method uses the key by the constructor. otherwise key = 1 """ # p...
[ "def", "decrypt_file", "(", "self", ",", "file", ",", "key", ")", ":", "# precondition", "assert", "(", "isinstance", "(", "file", ",", "str", ")", "and", "isinstance", "(", "key", ",", "int", ")", ")", "try", ":", "with", "open", "(", "file", ",", ...
[ 155, 4 ]
[ 177, 19 ]
python
en
['en', 'error', 'th']
False
AcceleratorConnector.check_interactive_compatibility
(self)
Raises a `MisconfigurationException` if the accelerator and/or plugin is not compatible with an interactive environment
Raises a `MisconfigurationException` if the accelerator and/or plugin is not compatible with an interactive environment
def check_interactive_compatibility(self): """ Raises a `MisconfigurationException` if the accelerator and/or plugin is not compatible with an interactive environment """ from pytorch_lightning.utilities import _IS_INTERACTIVE if _IS_INTERACTIVE and self._distrib_type is ...
[ "def", "check_interactive_compatibility", "(", "self", ")", ":", "from", "pytorch_lightning", ".", "utilities", "import", "_IS_INTERACTIVE", "if", "_IS_INTERACTIVE", "and", "self", ".", "_distrib_type", "is", "not", "None", "and", "not", "self", ".", "_distrib_type"...
[ 563, 4 ]
[ 574, 13 ]
python
en
['en', 'error', 'th']
False
AcceleratorConnector.check_horovod
(self)
Raises a `MisconfigurationException` if the Trainer is not configured correctly for Horovod.
Raises a `MisconfigurationException` if the Trainer is not configured correctly for Horovod.
def check_horovod(self): """Raises a `MisconfigurationException` if the Trainer is not configured correctly for Horovod.""" if not _HOROVOD_AVAILABLE: raise MisconfigurationException( 'Requested `distributed_backend="horovod"`, but Horovod is not installed.' "...
[ "def", "check_horovod", "(", "self", ")", ":", "if", "not", "_HOROVOD_AVAILABLE", ":", "raise", "MisconfigurationException", "(", "'Requested `distributed_backend=\"horovod\"`, but Horovod is not installed.'", "\"Install with \\n $HOROVOD_WITH_PYTORCH=1 pip install horovod[pytorch]\"", ...
[ 576, 4 ]
[ 588, 13 ]
python
en
['en', 'en', 'en']
True
AcceleratorConnector.has_horovodrun
()
Returns True if running with `horovodrun` using Gloo or OpenMPI.
Returns True if running with `horovodrun` using Gloo or OpenMPI.
def has_horovodrun() -> bool: """Returns True if running with `horovodrun` using Gloo or OpenMPI.""" return "OMPI_COMM_WORLD_RANK" in os.environ or "HOROVOD_RANK" in os.environ
[ "def", "has_horovodrun", "(", ")", "->", "bool", ":", "return", "\"OMPI_COMM_WORLD_RANK\"", "in", "os", ".", "environ", "or", "\"HOROVOD_RANK\"", "in", "os", ".", "environ" ]
[ 591, 4 ]
[ 593, 83 ]
python
en
['en', 'en', 'en']
True
buildmodule
(m, um)
Return
Return
def buildmodule(m, um): """ Return """ global f2py_version, options outmess('\tBuilding module "%s"...\n' % (m['name'])) ret = {} mod_rules = defmod_rules[:] vrd = capi_maps.modsign2map(m) rd = dictappend({'f2py_version': f2py_version}, vrd) funcwrappers = [] funcwrappers2 = ...
[ "def", "buildmodule", "(", "m", ",", "um", ")", ":", "global", "f2py_version", ",", "options", "outmess", "(", "'\\tBuilding module \"%s\"...\\n'", "%", "(", "m", "[", "'name'", "]", ")", ")", "ret", "=", "{", "}", "mod_rules", "=", "defmod_rules", "[", ...
[ 1160, 0 ]
[ 1334, 14 ]
python
en
['en', 'error', 'th']
False
setup_ddp
(rank, world_size)
Setup ddp enviroment
Setup ddp enviroment
def setup_ddp(rank, world_size): """ Setup ddp enviroment """ os.environ["MASTER_ADDR"] = "localhost" os.environ["MASTER_PORT"] = "8088" if torch.distributed.is_available() and sys.platform not in ("win32", "cygwin"): torch.distributed.init_process_group("gloo", rank=rank, world_size=world_size...
[ "def", "setup_ddp", "(", "rank", ",", "world_size", ")", ":", "os", ".", "environ", "[", "\"MASTER_ADDR\"", "]", "=", "\"localhost\"", "os", ".", "environ", "[", "\"MASTER_PORT\"", "]", "=", "\"8088\"", "if", "torch", ".", "distributed", ".", "is_available",...
[ 12, 0 ]
[ 18, 86 ]
python
en
['en', 'hi-Latn', 'hi']
False
_patch_comet_atexit
(monkeypatch)
Prevent comet logger from trying to print at exit, since pytest's stdout/stderr redirection breaks it.
Prevent comet logger from trying to print at exit, since pytest's stdout/stderr redirection breaks it.
def _patch_comet_atexit(monkeypatch): """ Prevent comet logger from trying to print at exit, since pytest's stdout/stderr redirection breaks it. """ import atexit monkeypatch.setattr(atexit, "register", lambda _: None)
[ "def", "_patch_comet_atexit", "(", "monkeypatch", ")", ":", "import", "atexit", "monkeypatch", ".", "setattr", "(", "atexit", ",", "\"register\"", ",", "lambda", "_", ":", "None", ")" ]
[ 24, 0 ]
[ 27, 59 ]
python
en
['en', 'en', 'en']
True
test_comet_logger_online
(comet)
Test comet online with mocks.
Test comet online with mocks.
def test_comet_logger_online(comet): """Test comet online with mocks.""" # Test api_key given with patch('pytorch_lightning.loggers.comet.CometExperiment') as comet_experiment: logger = CometLogger(api_key='key', workspace='dummy-test', project_name='general') _ = logger.experiment ...
[ "def", "test_comet_logger_online", "(", "comet", ")", ":", "# Test api_key given", "with", "patch", "(", "'pytorch_lightning.loggers.comet.CometExperiment'", ")", "as", "comet_experiment", ":", "logger", "=", "CometLogger", "(", "api_key", "=", "'key'", ",", "workspace"...
[ 31, 0 ]
[ 70, 43 ]
python
en
['en', 'da', 'en']
True
test_comet_logger_no_api_key_given
(comet)
Test that CometLogger fails to initialize if both api key and save_dir are missing.
Test that CometLogger fails to initialize if both api key and save_dir are missing.
def test_comet_logger_no_api_key_given(comet): """ Test that CometLogger fails to initialize if both api key and save_dir are missing. """ with pytest.raises(MisconfigurationException, match='requires either api_key or save_dir'): comet.config.get_api_key.return_value = None CometLogger(workspac...
[ "def", "test_comet_logger_no_api_key_given", "(", "comet", ")", ":", "with", "pytest", ".", "raises", "(", "MisconfigurationException", ",", "match", "=", "'requires either api_key or save_dir'", ")", ":", "comet", ".", "config", ".", "get_api_key", ".", "return_value...
[ 74, 0 ]
[ 78, 67 ]
python
en
['en', 'en', 'en']
True
test_comet_logger_experiment_name
(comet)
Test that Comet Logger experiment name works correctly.
Test that Comet Logger experiment name works correctly.
def test_comet_logger_experiment_name(comet): """Test that Comet Logger experiment name works correctly.""" api_key = "key" experiment_name = "My Name" # Test api_key given with patch('pytorch_lightning.loggers.comet.CometExperiment') as comet_experiment: logger = CometLogger( ...
[ "def", "test_comet_logger_experiment_name", "(", "comet", ")", ":", "api_key", "=", "\"key\"", "experiment_name", "=", "\"My Name\"", "# Test api_key given", "with", "patch", "(", "'pytorch_lightning.loggers.comet.CometExperiment'", ")", "as", "comet_experiment", ":", "logg...
[ 82, 0 ]
[ 98, 76 ]
python
en
['en', 'en', 'en']
True
test_comet_logger_manual_experiment_key
(comet)
Test that Comet Logger respects manually set COMET_EXPERIMENT_KEY.
Test that Comet Logger respects manually set COMET_EXPERIMENT_KEY.
def test_comet_logger_manual_experiment_key(comet): """Test that Comet Logger respects manually set COMET_EXPERIMENT_KEY.""" api_key = "key" experiment_key = "96346da91469407a85641afe5766b554" instantation_environ = {} def save_os_environ(*args, **kwargs): nonlocal instantation_environ ...
[ "def", "test_comet_logger_manual_experiment_key", "(", "comet", ")", ":", "api_key", "=", "\"key\"", "experiment_key", "=", "\"96346da91469407a85641afe5766b554\"", "instantation_environ", "=", "{", "}", "def", "save_os_environ", "(", "*", "args", ",", "*", "*", "kwarg...
[ 102, 0 ]
[ 126, 73 ]
python
en
['en', 'en', 'en']
True
test_comet_logger_dirs_creation
(comet, comet_experiment, tmpdir, monkeypatch)
Test that the logger creates the folders and files in the right place.
Test that the logger creates the folders and files in the right place.
def test_comet_logger_dirs_creation(comet, comet_experiment, tmpdir, monkeypatch): """ Test that the logger creates the folders and files in the right place. """ _patch_comet_atexit(monkeypatch) comet.config.get_api_key.return_value = None comet.generate_guid.return_value = "4321" logger = CometLo...
[ "def", "test_comet_logger_dirs_creation", "(", "comet", ",", "comet_experiment", ",", "tmpdir", ",", "monkeypatch", ")", ":", "_patch_comet_atexit", "(", "monkeypatch", ")", "comet", ".", "config", ".", "get_api_key", ".", "return_value", "=", "None", "comet", "."...
[ 131, 0 ]
[ 160, 45 ]
python
en
['en', 'en', 'en']
True
test_comet_name_default
(comet)
Test that CometLogger.name don't create an Experiment and returns a default value.
Test that CometLogger.name don't create an Experiment and returns a default value.
def test_comet_name_default(comet): """ Test that CometLogger.name don't create an Experiment and returns a default value. """ api_key = "key" with patch('pytorch_lightning.loggers.comet.CometExperiment'): logger = CometLogger(api_key=api_key) assert logger._experiment is None asse...
[ "def", "test_comet_name_default", "(", "comet", ")", ":", "api_key", "=", "\"key\"", "with", "patch", "(", "'pytorch_lightning.loggers.comet.CometExperiment'", ")", ":", "logger", "=", "CometLogger", "(", "api_key", "=", "api_key", ")", "assert", "logger", ".", "_...
[ 164, 0 ]
[ 173, 41 ]
python
en
['en', 'en', 'en']
True
test_comet_name_project_name
(comet)
Test that CometLogger.name does not create an Experiment and returns project name if passed.
Test that CometLogger.name does not create an Experiment and returns project name if passed.
def test_comet_name_project_name(comet): """ Test that CometLogger.name does not create an Experiment and returns project name if passed. """ api_key = "key" project_name = "My Project Name" with patch('pytorch_lightning.loggers.comet.CometExperiment'): logger = CometLogger(api_key=api_key, pr...
[ "def", "test_comet_name_project_name", "(", "comet", ")", ":", "api_key", "=", "\"key\"", "project_name", "=", "\"My Project Name\"", "with", "patch", "(", "'pytorch_lightning.loggers.comet.CometExperiment'", ")", ":", "logger", "=", "CometLogger", "(", "api_key", "=", ...
[ 177, 0 ]
[ 187, 41 ]
python
en
['en', 'en', 'en']
True
test_comet_version_without_experiment
(comet)
Test that CometLogger.version does not create an Experiment.
Test that CometLogger.version does not create an Experiment.
def test_comet_version_without_experiment(comet): """ Test that CometLogger.version does not create an Experiment. """ api_key = "key" experiment_name = "My Name" comet.generate_guid.return_value = "1234" with patch('pytorch_lightning.loggers.comet.CometExperiment'): logger = CometLogger(a...
[ "def", "test_comet_version_without_experiment", "(", "comet", ")", ":", "api_key", "=", "\"key\"", "experiment_name", "=", "\"My Name\"", "comet", ".", "generate_guid", ".", "return_value", "=", "\"1234\"", "with", "patch", "(", "'pytorch_lightning.loggers.comet.CometExpe...
[ 191, 0 ]
[ 213, 46 ]
python
en
['en', 'en', 'en']
True
test_comet_epoch_logging
(comet, comet_experiment, tmpdir, monkeypatch)
Test that CometLogger removes the epoch key from the metrics dict and passes it as argument.
Test that CometLogger removes the epoch key from the metrics dict and passes it as argument.
def test_comet_epoch_logging(comet, comet_experiment, tmpdir, monkeypatch): """ Test that CometLogger removes the epoch key from the metrics dict and passes it as argument. """ _patch_comet_atexit(monkeypatch) logger = CometLogger(project_name="test", save_dir=tmpdir) logger.log_metrics({"test": 1, "epo...
[ "def", "test_comet_epoch_logging", "(", "comet", ",", "comet_experiment", ",", "tmpdir", ",", "monkeypatch", ")", ":", "_patch_comet_atexit", "(", "monkeypatch", ")", "logger", "=", "CometLogger", "(", "project_name", "=", "\"test\"", ",", "save_dir", "=", "tmpdir...
[ 218, 0 ]
[ 223, 89 ]
python
en
['en', 'en', 'en']
True
create_app
(debug=False)
Create an application.
Create an application.
def create_app(debug=False): """Create an application.""" app = Flask(__name__) CORS(app) socketio.cors_allowed_origins = "*" socketio.init_app(app) # these imports required to be after socketio initialization from .main.config import MachineType from .main.model import PicoB...
[ "def", "create_app", "(", "debug", "=", "False", ")", ":", "app", "=", "Flask", "(", "__name__", ")", "CORS", "(", "app", ")", "socketio", ".", "cors_allowed_origins", "=", "\"*\"", "socketio", ".", "init_app", "(", "app", ")", "# these imports required to b...
[ 20, 0 ]
[ 115, 14 ]
python
en
['en', 'gd', 'en']
True
on_powerpc
()
True if we are running on a Power PC platform.
True if we are running on a Power PC platform.
def on_powerpc(): """ True if we are running on a Power PC platform.""" return platform.processor() == 'powerpc' or \ platform.machine().startswith('ppc')
[ "def", "on_powerpc", "(", ")", ":", "return", "platform", ".", "processor", "(", ")", "==", "'powerpc'", "or", "platform", ".", "machine", "(", ")", ".", "startswith", "(", "'ppc'", ")" ]
[ 19, 0 ]
[ 22, 47 ]
python
en
['en', 'en', 'en']
True
TestRoundingFunctions.test_object_direct
(self)
test direct implementation of these magic methods
test direct implementation of these magic methods
def test_object_direct(self): """ test direct implementation of these magic methods """ class C: def __floor__(self): return 1 def __ceil__(self): return 2 def __trunc__(self): return 3 arr = np.array([C(), C()]...
[ "def", "test_object_direct", "(", "self", ")", ":", "class", "C", ":", "def", "__floor__", "(", "self", ")", ":", "return", "1", "def", "__ceil__", "(", "self", ")", ":", "return", "2", "def", "__trunc__", "(", "self", ")", ":", "return", "3", "arr",...
[ 2517, 4 ]
[ 2530, 43 ]
python
en
['en', 'en', 'en']
True
TestRoundingFunctions.test_object_indirect
(self)
test implementations via __float__
test implementations via __float__
def test_object_indirect(self): """ test implementations via __float__ """ class C: def __float__(self): return -2.5 arr = np.array([C(), C()]) assert_equal(np.floor(arr), [-3, -3]) assert_equal(np.ceil(arr), [-2, -2]) with pytest.raises(Type...
[ "def", "test_object_indirect", "(", "self", ")", ":", "class", "C", ":", "def", "__float__", "(", "self", ")", ":", "return", "-", "2.5", "arr", "=", "np", ".", "array", "(", "[", "C", "(", ")", ",", "C", "(", ")", "]", ")", "assert_equal", "(", ...
[ 2532, 4 ]
[ 2542, 25 ]
python
en
['en', 'fr', 'en']
True
test_invalid_weights_summmary
()
Test that invalid value for weights_summary raises an error.
Test that invalid value for weights_summary raises an error.
def test_invalid_weights_summmary(): """ Test that invalid value for weights_summary raises an error. """ with pytest.raises(MisconfigurationException, match='`mode` can be None, .* got temp'): UnorderedModel().summarize(mode='temp') with pytest.raises(MisconfigurationException, match='`weights_sum...
[ "def", "test_invalid_weights_summmary", "(", ")", ":", "with", "pytest", ".", "raises", "(", "MisconfigurationException", ",", "match", "=", "'`mode` can be None, .* got temp'", ")", ":", "UnorderedModel", "(", ")", ".", "summarize", "(", "mode", "=", "'temp'", ")...
[ 90, 0 ]
[ 96, 39 ]
python
en
['en', 'en', 'en']
True
test_empty_model_summary_shapes
(mode)
Test that the summary works for models that have no submodules.
Test that the summary works for models that have no submodules.
def test_empty_model_summary_shapes(mode): """ Test that the summary works for models that have no submodules. """ model = EmptyModule() summary = model.summarize(mode=mode) assert summary.in_sizes == [] assert summary.out_sizes == [] assert summary.param_nums == []
[ "def", "test_empty_model_summary_shapes", "(", "mode", ")", ":", "model", "=", "EmptyModule", "(", ")", "summary", "=", "model", ".", "summarize", "(", "mode", "=", "mode", ")", "assert", "summary", ".", "in_sizes", "==", "[", "]", "assert", "summary", "."...
[ 103, 0 ]
[ 109, 35 ]
python
en
['en', 'en', 'en']
True
test_linear_model_summary_shapes
(device, mode)
Test that the model summary correctly computes the input- and output shapes.
Test that the model summary correctly computes the input- and output shapes.
def test_linear_model_summary_shapes(device, mode): """ Test that the model summary correctly computes the input- and output shapes. """ model = UnorderedModel().to(device) model.train() summary = model.summarize(mode=mode) assert summary.in_sizes == [ [2, 10], # layer 2 [2, 7], # ...
[ "def", "test_linear_model_summary_shapes", "(", "device", ",", "mode", ")", ":", "model", "=", "UnorderedModel", "(", ")", ".", "to", "(", "device", ")", "model", ".", "train", "(", ")", "summary", "=", "model", ".", "summarize", "(", "mode", "=", "mode"...
[ 122, 0 ]
[ 142, 33 ]
python
en
['en', 'en', 'en']
True
test_mixed_dtype_model_summary
()
Test that the model summary works with models that have mixed input- and parameter dtypes.
Test that the model summary works with models that have mixed input- and parameter dtypes.
def test_mixed_dtype_model_summary(): """ Test that the model summary works with models that have mixed input- and parameter dtypes. """ model = MixedDtypeModel() summary = model.summarize() assert summary.in_sizes == [ [2, 3], # embed [2, 3, 20], # reduce ] assert summary.out_...
[ "def", "test_mixed_dtype_model_summary", "(", ")", ":", "model", "=", "MixedDtypeModel", "(", ")", "summary", "=", "model", ".", "summarize", "(", ")", "assert", "summary", ".", "in_sizes", "==", "[", "[", "2", ",", "3", "]", ",", "# embed", "[", "2", ...
[ 145, 0 ]
[ 156, 5 ]
python
en
['en', 'en', 'en']
True
test_hooks_removed_after_summarize
(mode)
Test that all hooks were properly removed after summary, even ones that were not run.
Test that all hooks were properly removed after summary, even ones that were not run.
def test_hooks_removed_after_summarize(mode): """ Test that all hooks were properly removed after summary, even ones that were not run. """ model = UnorderedModel() summary = ModelSummary(model, mode=mode) # hooks should be removed for _, layer in summary.summarize().items(): handle = layer....
[ "def", "test_hooks_removed_after_summarize", "(", "mode", ")", ":", "model", "=", "UnorderedModel", "(", ")", "summary", "=", "ModelSummary", "(", "model", ",", "mode", "=", "mode", ")", "# hooks should be removed", "for", "_", ",", "layer", "in", "summary", "...
[ 163, 0 ]
[ 170, 55 ]
python
en
['en', 'en', 'en']
True
test_rnn_summary_shapes
(mode)
Test that the model summary works for RNNs.
Test that the model summary works for RNNs.
def test_rnn_summary_shapes(mode): """ Test that the model summary works for RNNs. """ model = ParityModuleRNN() b = 3 t = 5 i = model.rnn.input_size h = model.rnn.hidden_size o = model.linear_out.out_features model.example_input_array = torch.zeros(b, t, 10) summary = model.summa...
[ "def", "test_rnn_summary_shapes", "(", "mode", ")", ":", "model", "=", "ParityModuleRNN", "(", ")", "b", "=", "3", "t", "=", "5", "i", "=", "model", ".", "rnn", ".", "input_size", "h", "=", "model", ".", "rnn", ".", "hidden_size", "o", "=", "model", ...
[ 177, 0 ]
[ 197, 5 ]
python
en
['en', 'en', 'en']
True
test_summary_parameter_count
(mode)
Test that the summary counts the number of parameters in every submodule.
Test that the summary counts the number of parameters in every submodule.
def test_summary_parameter_count(mode): """ Test that the summary counts the number of parameters in every submodule. """ model = UnorderedModel() summary = model.summarize(mode=mode) assert summary.param_nums == [ model.layer2.weight.numel() + model.layer2.bias.numel(), model.combine.we...
[ "def", "test_summary_parameter_count", "(", "mode", ")", ":", "model", "=", "UnorderedModel", "(", ")", "summary", "=", "model", ".", "summarize", "(", "mode", "=", "mode", ")", "assert", "summary", ".", "param_nums", "==", "[", "model", ".", "layer2", "."...
[ 204, 0 ]
[ 214, 5 ]
python
en
['en', 'en', 'en']
True
test_summary_layer_types
(mode)
Test that the summary displays the layer names correctly.
Test that the summary displays the layer names correctly.
def test_summary_layer_types(mode): """ Test that the summary displays the layer names correctly. """ model = UnorderedModel() summary = model.summarize(mode=mode) assert summary.layer_types == [ 'Linear', 'Linear', 'Linear', 'ReLU', 'Conv2d', ]
[ "def", "test_summary_layer_types", "(", "mode", ")", ":", "model", "=", "UnorderedModel", "(", ")", "summary", "=", "model", ".", "summarize", "(", "mode", "=", "mode", ")", "assert", "summary", ".", "layer_types", "==", "[", "'Linear'", ",", "'Linear'", "...
[ 221, 0 ]
[ 231, 5 ]
python
en
['en', 'en', 'en']
True
test_example_input_array_types
(example_input, expected_size, mode)
Test the types of example inputs supported for display in the summary.
Test the types of example inputs supported for display in the summary.
def test_example_input_array_types(example_input, expected_size, mode): """ Test the types of example inputs supported for display in the summary. """ class DummyModule(nn.Module): def forward(self, *args, **kwargs): return None class DummyLightningModule(LightningModule): de...
[ "def", "test_example_input_array_types", "(", "example_input", ",", "expected_size", ",", "mode", ")", ":", "class", "DummyModule", "(", "nn", ".", "Module", ")", ":", "def", "forward", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "r...
[ 247, 0 ]
[ 268, 46 ]
python
en
['en', 'en', 'en']
True
test_model_size
(mode)
Test model size is calculated correctly.
Test model size is calculated correctly.
def test_model_size(mode): """ Test model size is calculated correctly. """ model = PreCalculatedModel() summary = model.summarize(mode=mode) assert model.pre_calculated_model_size == summary.model_size
[ "def", "test_model_size", "(", "mode", ")", ":", "model", "=", "PreCalculatedModel", "(", ")", "summary", "=", "model", ".", "summarize", "(", "mode", "=", "mode", ")", "assert", "model", ".", "pre_calculated_model_size", "==", "summary", ".", "model_size" ]
[ 275, 0 ]
[ 279, 64 ]
python
en
['en', 'en', 'en']
True
test_empty_model_size
(mode)
Test empty model size is zero.
Test empty model size is zero.
def test_empty_model_size(mode): """ Test empty model size is zero. """ model = EmptyModule() summary = model.summarize(mode=mode) assert 0.0 == summary.model_size
[ "def", "test_empty_model_size", "(", "mode", ")", ":", "model", "=", "EmptyModule", "(", ")", "summary", "=", "model", ".", "summarize", "(", "mode", "=", "mode", ")", "assert", "0.0", "==", "summary", ".", "model_size" ]
[ 286, 0 ]
[ 290, 36 ]
python
en
['nl', 'pl', 'en']
False
test_model_size_precision
(monkeypatch, tmpdir, precision)
Test model size for half and full precision.
Test model size for half and full precision.
def test_model_size_precision(monkeypatch, tmpdir, precision): """ Test model size for half and full precision. """ model = PreCalculatedModel(precision) # fit model trainer = Trainer( default_root_dir=tmpdir, gpus=1, max_steps=1, max_epochs=1, precision=precisio...
[ "def", "test_model_size_precision", "(", "monkeypatch", ",", "tmpdir", ",", "precision", ")", ":", "model", "=", "PreCalculatedModel", "(", "precision", ")", "# fit model", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "gpus", "=", "1",...
[ 301, 0 ]
[ 315, 64 ]
python
en
['en', 'en', 'en']
True
TestHalf.test_half_conversions
(self)
Checks that all 16-bit values survive conversion to/from 32-bit and 64-bit float
Checks that all 16-bit values survive conversion to/from 32-bit and 64-bit float
def test_half_conversions(self): """Checks that all 16-bit values survive conversion to/from 32-bit and 64-bit float""" # Because the underlying routines preserve the NaN bits, every # value is preserved when converting to/from other floats. # Convert from float32 back to flo...
[ "def", "test_half_conversions", "(", "self", ")", ":", "# Because the underlying routines preserve the NaN bits, every", "# value is preserved when converting to/from other floats.", "# Convert from float32 back to float16", "b", "=", "np", ".", "array", "(", "self", ".", "all_f32"...
[ 41, 4 ]
[ 69, 30 ]
python
en
['en', 'fr', 'en']
True
TestHalf.test_half_values
(self)
Confirms a small number of known half values
Confirms a small number of known half values
def test_half_values(self): """Confirms a small number of known half values""" a = np.array([1.0, -1.0, 2.0, -2.0, 0.0999755859375, 0.333251953125, # 1/10, 1/3 65504, -65504, # Maximum magnitude 2.0**(-14)...
[ "def", "test_half_values", "(", "self", ")", ":", "a", "=", "np", ".", "array", "(", "[", "1.0", ",", "-", "1.0", ",", "2.0", ",", "-", "2.0", ",", "0.0999755859375", ",", "0.333251953125", ",", "# 1/10, 1/3", "65504", ",", "-", "65504", ",", "# Maxi...
[ 180, 4 ]
[ 199, 26 ]
python
en
['en', 'en', 'en']
True
TestHalf.test_half_rounding
(self)
Checks that rounding when converting to half is correct
Checks that rounding when converting to half is correct
def test_half_rounding(self): """Checks that rounding when converting to half is correct""" a = np.array([2.0**-25 + 2.0**-35, # Rounds to minimum subnormal 2.0**-25, # Underflows to zero (nearest even mode) 2.0**-26, # Underflows to zero ...
[ "def", "test_half_rounding", "(", "self", ")", ":", "a", "=", "np", ".", "array", "(", "[", "2.0", "**", "-", "25", "+", "2.0", "**", "-", "35", ",", "# Rounds to minimum subnormal", "2.0", "**", "-", "25", ",", "# Underflows to zero (nearest even mode)", ...
[ 201, 4 ]
[ 228, 32 ]
python
en
['en', 'en', 'en']
True
TestHalf.test_half_correctness
(self)
Take every finite float16, and check the casting functions with a manual conversion.
Take every finite float16, and check the casting functions with a manual conversion.
def test_half_correctness(self): """Take every finite float16, and check the casting functions with a manual conversion.""" # Create an array of all finite float16s a_bits = self.finite_f16.view(dtype=uint16) # Convert to 64-bit float manually a_sgn = (-1.0)**((a_bit...
[ "def", "test_half_correctness", "(", "self", ")", ":", "# Create an array of all finite float16s", "a_bits", "=", "self", ".", "finite_f16", ".", "view", "(", "dtype", "=", "uint16", ")", "# Convert to 64-bit float manually", "a_sgn", "=", "(", "-", "1.0", ")", "*...
[ 230, 4 ]
[ 264, 50 ]
python
en
['en', 'en', 'en']
True
TestHalf.test_half_ordering
(self)
Make sure comparisons are working right
Make sure comparisons are working right
def test_half_ordering(self): """Make sure comparisons are working right""" # All non-NaN float16 values in reverse order a = self.nonan_f16[::-1].copy() # 32-bit float copy b = np.array(a, dtype=float32) # Should sort the same a.sort() b.sort() ...
[ "def", "test_half_ordering", "(", "self", ")", ":", "# All non-NaN float16 values in reverse order", "a", "=", "self", ".", "nonan_f16", "[", ":", ":", "-", "1", "]", ".", "copy", "(", ")", "# 32-bit float copy", "b", "=", "np", ".", "array", "(", "a", ","...
[ 266, 4 ]
[ 287, 66 ]
python
en
['en', 'en', 'en']
True
TestHalf.test_half_funcs
(self)
Test the various ArrFuncs
Test the various ArrFuncs
def test_half_funcs(self): """Test the various ArrFuncs""" # fill assert_equal(np.arange(10, dtype=float16), np.arange(10, dtype=float32)) # fillwithscalar a = np.zeros((5,), dtype=float16) a.fill(1) assert_equal(a, np.ones((5,), dtype=float...
[ "def", "test_half_funcs", "(", "self", ")", ":", "# fill", "assert_equal", "(", "np", ".", "arange", "(", "10", ",", "dtype", "=", "float16", ")", ",", "np", ".", "arange", "(", "10", ",", "dtype", "=", "float32", ")", ")", "# fillwithscalar", "a", "...
[ 289, 4 ]
[ 326, 38 ]
python
en
['en', 'su', 'en']
True
TestHalf.test_spacing_nextafter
(self)
Test np.spacing and np.nextafter
Test np.spacing and np.nextafter
def test_spacing_nextafter(self): """Test np.spacing and np.nextafter""" # All non-negative finite #'s a = np.arange(0x7c00, dtype=uint16) hinf = np.array((np.inf,), dtype=float16) a_f16 = a.view(dtype=float16) assert_equal(np.spacing(a_f16[:-1]), a_f16[1:]-a_f16[:-1]) ...
[ "def", "test_spacing_nextafter", "(", "self", ")", ":", "# All non-negative finite #'s", "a", "=", "np", ".", "arange", "(", "0x7c00", ",", "dtype", "=", "uint16", ")", "hinf", "=", "np", ".", "array", "(", "(", "np", ".", "inf", ",", ")", ",", "dtype"...
[ 328, 4 ]
[ 349, 64 ]
python
en
['en', 'en', 'en']
True
TestHalf.test_half_ufuncs
(self)
Test the various ufuncs
Test the various ufuncs
def test_half_ufuncs(self): """Test the various ufuncs""" a = np.array([0, 1, 2, 4, 2], dtype=float16) b = np.array([-2, 5, 1, 4, 3], dtype=float16) c = np.array([0, -1, -np.inf, np.nan, 6], dtype=float16) assert_equal(np.add(a, b), [-2, 6, 3, 8, 5]) assert_equal(np.sub...
[ "def", "test_half_ufuncs", "(", "self", ")", ":", "a", "=", "np", ".", "array", "(", "[", "0", ",", "1", ",", "2", ",", "4", ",", "2", "]", ",", "dtype", "=", "float16", ")", "b", "=", "np", ".", "array", "(", "[", "-", "2", ",", "5", ","...
[ 351, 4 ]
[ 413, 71 ]
python
en
['en', 'su', 'en']
True
TestHalf.test_half_coercion
(self)
Test that half gets coerced properly with the other types
Test that half gets coerced properly with the other types
def test_half_coercion(self): """Test that half gets coerced properly with the other types""" a16 = np.array((1,), dtype=float16) a32 = np.array((1,), dtype=float32) b16 = float16(1) b32 = float32(1) assert_equal(np.power(a16, 2).dtype, float16) assert_equal(np.p...
[ "def", "test_half_coercion", "(", "self", ")", ":", "a16", "=", "np", ".", "array", "(", "(", "1", ",", ")", ",", "dtype", "=", "float16", ")", "a32", "=", "np", ".", "array", "(", "(", "1", ",", ")", ",", "dtype", "=", "float32", ")", "b16", ...
[ 415, 4 ]
[ 439, 55 ]
python
en
['en', 'en', 'en']
True
TestHalf.test_half_array_interface
(self)
Test that half is compatible with __array_interface__
Test that half is compatible with __array_interface__
def test_half_array_interface(self): """Test that half is compatible with __array_interface__""" class Dummy: pass a = np.ones((1,), dtype=float16) b = Dummy() b.__array_interface__ = a.__array_interface__ c = np.array(b) assert_(c.dtype == float16) ...
[ "def", "test_half_array_interface", "(", "self", ")", ":", "class", "Dummy", ":", "pass", "a", "=", "np", ".", "ones", "(", "(", "1", ",", ")", ",", "dtype", "=", "float16", ")", "b", "=", "Dummy", "(", ")", "b", ".", "__array_interface__", "=", "a...
[ 507, 4 ]
[ 517, 26 ]
python
en
['en', 'en', 'en']
True
ConfluenceRestClient.get_content
(self, start=0, limit=100, type="page", expand="space")
Returns all content. This only includes pages that the user has permission to view. :param start: The starting index of the returned boards. Base index: 0. :param limit: The maximum number of boards to return per page. Default: 50. :param type: the content type to return. Default value:...
Returns all content. This only includes pages that the user has permission to view. :param start: The starting index of the returned boards. Base index: 0. :param limit: The maximum number of boards to return per page. Default: 50. :param type: the content type to return. Default value:...
def get_content(self, start=0, limit=100, type="page", expand="space"): """ Returns all content. This only includes pages that the user has permission to view. :param start: The starting index of the returned boards. Base index: 0. :param limit: The maximum number of boards to return per...
[ "def", "get_content", "(", "self", ",", "start", "=", "0", ",", "limit", "=", "100", ",", "type", "=", "\"page\"", ",", "expand", "=", "\"space\"", ")", ":", "BATCH_SIZE_SEARCH", "=", "200", "loop_count", "=", "limit", "//", "BATCH_SIZE_SEARCH", "+", "1"...
[ 10, 4 ]
[ 44, 22 ]
python
en
['en', 'error', 'th']
False
ConfluenceRestClient.get_content_search
(self, start=0, limit=100, cql=None, expand="space")
Fetch a list of content using the Confluence Query Language (CQL). :param start: The starting index of the returned boards. Base index: 0. :param limit: The maximum number of boards to return per page. Default: 50. :param cql: Filters results to boards of the specified type. Valid value...
Fetch a list of content using the Confluence Query Language (CQL). :param start: The starting index of the returned boards. Base index: 0. :param limit: The maximum number of boards to return per page. Default: 50. :param cql: Filters results to boards of the specified type. Valid value...
def get_content_search(self, start=0, limit=100, cql=None, expand="space"): """ Fetch a list of content using the Confluence Query Language (CQL). :param start: The starting index of the returned boards. Base index: 0. :param limit: The maximum number of boards to return per page. Defaul...
[ "def", "get_content_search", "(", "self", ",", "start", "=", "0", ",", "limit", "=", "100", ",", "cql", "=", "None", ",", "expand", "=", "\"space\"", ")", ":", "BATCH_SIZE_SEARCH", "=", "200", "loop_count", "=", "limit", "//", "BATCH_SIZE_SEARCH", "+", "...
[ 46, 4 ]
[ 80, 22 ]
python
en
['en', 'error', 'th']
False
ConfluenceRestClient.search
(self, cql, cqlcontext=None, expand=None, start=0, limit=500)
Fetch a list of content using the Confluence Query Language (CQL). :param cql: a cql query string to use to locate content :param cqlcontext: the context to execute a cql search in, this is the json serialized form of SearchContext :param expand: a comma separated list of properties to ...
Fetch a list of content using the Confluence Query Language (CQL). :param cql: a cql query string to use to locate content :param cqlcontext: the context to execute a cql search in, this is the json serialized form of SearchContext :param expand: a comma separated list of properties to ...
def search(self, cql, cqlcontext=None, expand=None, start=0, limit=500): """ Fetch a list of content using the Confluence Query Language (CQL). :param cql: a cql query string to use to locate content :param cqlcontext: the context to execute a cql search in, this is the json serialized f...
[ "def", "search", "(", "self", ",", "cql", ",", "cqlcontext", "=", "None", ",", "expand", "=", "None", ",", "start", "=", "0", ",", "limit", "=", "500", ")", ":", "loop_count", "=", "limit", "//", "BATCH_SIZE_SEARCH", "+", "1", "last_loop_remainder", "=...
[ 96, 4 ]
[ 122, 34 ]
python
en
['en', 'error', 'th']
False
ConfluenceRpcClient.create_user
(self, username=None, password=None)
Creates user. Uses XML-RPC protocol (https://developer.atlassian.com/server/confluence/confluence-xml-rpc-and-soap-apis/) :param username: Username to create :param password: Password for user :return: user
Creates user. Uses XML-RPC protocol (https://developer.atlassian.com/server/confluence/confluence-xml-rpc-and-soap-apis/) :param username: Username to create :param password: Password for user :return: user
def create_user(self, username=None, password=None): """ Creates user. Uses XML-RPC protocol (https://developer.atlassian.com/server/confluence/confluence-xml-rpc-and-soap-apis/) :param username: Username to create :param password: Password for user :return: user ...
[ "def", "create_user", "(", "self", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "proxy", "=", "xmlrpc", ".", "client", ".", "ServerProxy", "(", "self", ".", "host", "+", "\"/rpc/xmlrpc\"", ")", "token", "=", "proxy", ".", "conf...
[ 167, 4 ]
[ 189, 82 ]
python
en
['en', 'error', 'th']
False
EvalModelTemplate.__build_model
(self)
Simple model for testing :return:
Simple model for testing :return:
def __build_model(self): """ Simple model for testing :return: """ self.c_d1 = nn.Linear(in_features=self.in_features, out_features=self.hidden_dim) self.c_d1_bn = nn.BatchNorm1d(self.hidden_dim) self.c_d1_drop = nn.Dropout(self.drop_prob) self.c_d2 = nn....
[ "def", "__build_model", "(", "self", ")", ":", "self", ".", "c_d1", "=", "nn", ".", "Linear", "(", "in_features", "=", "self", ".", "in_features", ",", "out_features", "=", "self", ".", "hidden_dim", ")", "self", ".", "c_d1_bn", "=", "nn", ".", "BatchN...
[ 95, 4 ]
[ 104, 90 ]
python
en
['en', 'error', 'th']
False
main
()
Visualize the demo images. Require the json_file containing boxes.
Visualize the demo images.
def main(): """Visualize the demo images. Require the json_file containing boxes. """ parser = ArgumentParser() parser.add_argument('pose_config', help='Config file for detection') parser.add_argument('pose_checkpoint', help='Checkpoint file') parser.add_argument('--img-root', type=str, def...
[ "def", "main", "(", ")", ":", "parser", "=", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'pose_config'", ",", "help", "=", "'Config file for detection'", ")", "parser", ".", "add_argument", "(", "'pose_checkpoint'", ",", "help", "=", "'Che...
[ 9, 0 ]
[ 98, 30 ]
python
en
['en', 'en', 'en']
True
BaseProfiler.__init__
(self, output_streams: Optional[Union[list, tuple]] = None)
Args: output_streams: callable
Args: output_streams: callable
def __init__(self, output_streams: Optional[Union[list, tuple]] = None): """ Args: output_streams: callable """ if output_streams: if not isinstance(output_streams, (list, tuple)): output_streams = [output_streams] else: output_...
[ "def", "__init__", "(", "self", ",", "output_streams", ":", "Optional", "[", "Union", "[", "list", ",", "tuple", "]", "]", "=", "None", ")", ":", "if", "output_streams", ":", "if", "not", "isinstance", "(", "output_streams", ",", "(", "list", ",", "tup...
[ 41, 4 ]
[ 51, 43 ]
python
en
['en', 'error', 'th']
False
BaseProfiler.start
(self, action_name: str)
Defines how to start recording an action.
Defines how to start recording an action.
def start(self, action_name: str) -> None: """Defines how to start recording an action."""
[ "def", "start", "(", "self", ",", "action_name", ":", "str", ")", "->", "None", ":" ]
[ 54, 4 ]
[ 55, 55 ]
python
en
['en', 'en', 'en']
True
BaseProfiler.stop
(self, action_name: str)
Defines how to record the duration once an action is complete.
Defines how to record the duration once an action is complete.
def stop(self, action_name: str) -> None: """Defines how to record the duration once an action is complete."""
[ "def", "stop", "(", "self", ",", "action_name", ":", "str", ")", "->", "None", ":" ]
[ 58, 4 ]
[ 59, 76 ]
python
en
['en', 'en', 'en']
True
BaseProfiler.profile
(self, action_name: str)
Yields a context manager to encapsulate the scope of a profiled action. Example:: with self.profile('load training data'): # load training data code The profiler will start once you've entered the context and will automatically stop once you exit the code ...
Yields a context manager to encapsulate the scope of a profiled action.
def profile(self, action_name: str) -> None: """ Yields a context manager to encapsulate the scope of a profiled action. Example:: with self.profile('load training data'): # load training data code The profiler will start once you've entered the context and...
[ "def", "profile", "(", "self", ",", "action_name", ":", "str", ")", "->", "None", ":", "try", ":", "self", ".", "start", "(", "action_name", ")", "yield", "action_name", "finally", ":", "self", ".", "stop", "(", "action_name", ")" ]
[ 62, 4 ]
[ 78, 34 ]
python
en
['en', 'error', 'th']
False
BaseProfiler.describe
(self)
Logs a profile report after the conclusion of the training run.
Logs a profile report after the conclusion of the training run.
def describe(self) -> None: """Logs a profile report after the conclusion of the training run.""" for write in self.write_streams: write(self.summary())
[ "def", "describe", "(", "self", ")", "->", "None", ":", "for", "write", "in", "self", ".", "write_streams", ":", "write", "(", "self", ".", "summary", "(", ")", ")" ]
[ 92, 4 ]
[ 95, 33 ]
python
en
['en', 'en', 'en']
True
BaseProfiler.summary
(self)
Create profiler summary in text format.
Create profiler summary in text format.
def summary(self) -> str: """Create profiler summary in text format."""
[ "def", "summary", "(", "self", ")", "->", "str", ":" ]
[ 98, 4 ]
[ 99, 53 ]
python
en
['en', 'en', 'en']
True
SimpleProfiler.__init__
(self, output_filename: Optional[str] = None, extended=True)
Args: output_filename: optionally save profile results to file instead of printing to std out when training is finished.
Args: output_filename: optionally save profile results to file instead of printing to std out when training is finished.
def __init__(self, output_filename: Optional[str] = None, extended=True): """ Args: output_filename: optionally save profile results to file instead of printing to std out when training is finished. """ self.current_actions = {} self.recorded_durations...
[ "def", "__init__", "(", "self", ",", "output_filename", ":", "Optional", "[", "str", "]", "=", "None", ",", "extended", "=", "True", ")", ":", "self", ".", "current_actions", "=", "{", "}", "self", ".", "recorded_durations", "=", "defaultdict", "(", "lis...
[ 130, 4 ]
[ 148, 54 ]
python
en
['en', 'error', 'th']
False
SimpleProfiler.describe
(self)
Logs a profile report after the conclusion of the training run.
Logs a profile report after the conclusion of the training run.
def describe(self): """Logs a profile report after the conclusion of the training run.""" super().describe() if self.output_file: self.output_file.flush()
[ "def", "describe", "(", "self", ")", ":", "super", "(", ")", ".", "describe", "(", ")", "if", "self", ".", "output_file", ":", "self", ".", "output_file", ".", "flush", "(", ")" ]
[ 209, 4 ]
[ 213, 36 ]
python
en
['en', 'en', 'en']
True
SimpleProfiler.__del__
(self)
Close profiler's stream.
Close profiler's stream.
def __del__(self): """Close profiler's stream.""" if self.output_file: self.output_file.close()
[ "def", "__del__", "(", "self", ")", ":", "if", "self", ".", "output_file", ":", "self", ".", "output_file", ".", "close", "(", ")" ]
[ 215, 4 ]
[ 218, 36 ]
python
en
['en', 'pt', 'en']
True
AdvancedProfiler.__init__
(self, output_filename: Optional[str] = None, line_count_restriction: float = 1.0)
Args: output_filename: optionally save profile results to file instead of printing to std out when training is finished. line_count_restriction: this can be used to limit the number of functions reported for each action. either an integer (to select a cou...
Args: output_filename: optionally save profile results to file instead of printing to std out when training is finished. line_count_restriction: this can be used to limit the number of functions reported for each action. either an integer (to select a cou...
def __init__(self, output_filename: Optional[str] = None, line_count_restriction: float = 1.0): """ Args: output_filename: optionally save profile results to file instead of printing to std out when training is finished. line_count_restriction: this can be used to...
[ "def", "__init__", "(", "self", ",", "output_filename", ":", "Optional", "[", "str", "]", "=", "None", ",", "line_count_restriction", ":", "float", "=", "1.0", ")", ":", "self", ".", "profiled_actions", "=", "{", "}", "self", ".", "line_count_restriction", ...
[ 228, 4 ]
[ 247, 54 ]
python
en
['en', 'error', 'th']
False
AdvancedProfiler.describe
(self)
Logs a profile report after the conclusion of the training run.
Logs a profile report after the conclusion of the training run.
def describe(self): """Logs a profile report after the conclusion of the training run.""" super().describe() if self.output_file: self.output_file.flush()
[ "def", "describe", "(", "self", ")", ":", "super", "(", ")", ".", "describe", "(", ")", "if", "self", ".", "output_file", ":", "self", ".", "output_file", ".", "flush", "(", ")" ]
[ 277, 4 ]
[ 281, 36 ]
python
en
['en', 'en', 'en']
True
AdvancedProfiler.__del__
(self)
Close profiler's stream.
Close profiler's stream.
def __del__(self): """Close profiler's stream.""" if self.output_file: self.output_file.close()
[ "def", "__del__", "(", "self", ")", ":", "if", "self", ".", "output_file", ":", "self", ".", "output_file", ".", "close", "(", ")" ]
[ 283, 4 ]
[ 286, 36 ]
python
en
['en', 'pt', 'en']
True
PyTorchProfiler.__init__
( self, output_filename: Optional[str] = None, enabled: bool = True, use_cuda: bool = False, record_shapes: bool = False, profile_memory: bool = False, group_by_input_shapes: bool = False, with_stack: bool = False, use_kineto: bool = False, ...
This profiler uses PyTorch's Autograd Profiler and lets you inspect the cost of different operators inside your model - both on the CPU and GPU Args: output_filename: optionally save profile results to file instead of printing to std out when training is finished. ...
This profiler uses PyTorch's Autograd Profiler and lets you inspect the cost of different operators inside your model - both on the CPU and GPU
def __init__( self, output_filename: Optional[str] = None, enabled: bool = True, use_cuda: bool = False, record_shapes: bool = False, profile_memory: bool = False, group_by_input_shapes: bool = False, with_stack: bool = False, use_kineto: bool = Fa...
[ "def", "__init__", "(", "self", ",", "output_filename", ":", "Optional", "[", "str", "]", "=", "None", ",", "enabled", ":", "bool", "=", "True", ",", "use_cuda", ":", "bool", "=", "False", ",", "record_shapes", ":", "bool", "=", "False", ",", "profile_...
[ 304, 4 ]
[ 416, 56 ]
python
en
['en', 'error', 'th']
False
PyTorchProfiler.describe
(self)
Logs a profile report after the conclusion of the training run.
Logs a profile report after the conclusion of the training run.
def describe(self): """Logs a profile report after the conclusion of the training run.""" super().describe() if self.output_file: self.output_file.flush()
[ "def", "describe", "(", "self", ")", ":", "super", "(", ")", ".", "describe", "(", ")", "if", "self", ".", "output_file", ":", "self", ".", "output_file", ".", "flush", "(", ")" ]
[ 535, 4 ]
[ 539, 36 ]
python
en
['en', 'en', 'en']
True
PyTorchProfiler.__del__
(self)
Close profiler's stream.
Close profiler's stream.
def __del__(self): """Close profiler's stream.""" if self.output_file: self.output_file.close()
[ "def", "__del__", "(", "self", ")", ":", "if", "self", ".", "output_file", ":", "self", ".", "output_file", ".", "close", "(", ")" ]
[ 541, 4 ]
[ 544, 36 ]
python
en
['en', 'pt', 'en']
True
Checker.diff
(self)
Flag to determine whether the checker should print diffs to the console
Flag to determine whether the checker should print diffs to the console
def diff(self) -> bool: """Flag to determine whether the checker should print diffs to the console""" return self.args.diff
[ "def", "diff", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "args", ".", "diff" ]
[ 23, 4 ]
[ 25, 29 ]
python
en
['en', 'en', 'en']
True